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 
<https://github.com/prometheus/client_python/blob/2ff532839fd54d7c686837e5955ea0ff9abfab76/prometheus_client/metrics.py#L119C58-L119C66>
) would try to create the metric/collector again (here 
<https://github.com/prometheus/client_python/blob/2ff532839fd54d7c686837e5955ea0ff9abfab76/prometheus_client/metrics.py#L142>).
 
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*


-- 
You received this message because you are subscribed to the Google Groups 
"Prometheus Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-developers/09162890-f82d-4af2-bb80-a4901e73c23fn%40googlegroups.com.

Reply via email to