[Feature/Proposal][python]: Ability to fetch a registered metric/collector on CollectorRegistry

51 views
Skip to first unread message

Prateek Lohchubh

unread,
Sep 19, 2023, 2:44:43 AM9/19/23
to Prometheus Developers
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:
  • Metric Name
  • Metric Type

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


Reply all
Reply to author
Forward
0 new messages