Hey,
Not sure if this already exists or not as I couldn't find it in the docs or in the code but the proposal/feature request is as follows:
Allow CollectorRegistry to have a method which can be used to fetch/get registered metrics by:
Currently, if you try to define/use the same metric again someplace else in code to use/push a new metric value out the default
registry=REGISTRY (
here)
would try to create the metric/collector again (
here). Moreover, the only way to check if a Collector/Metric is defined on the Registry is to lookup
_names_to_collectors which ideally shouldn't be accessed by clients directly.
In the current structure I believe the expectation is to have the metric defined ONLY ONCE and for the created metric/collector to be made available globally to be used to push out new values for the metric and the transient bg tasks to push metrics directly via pushgateway