How to get a registered Metric
Hi,
I'm parsing some YAML and making it into Counters and Gauges.
Sometimes some YAML might redefine a metric (name / help / type), which will then be set with different label values. In this case when I add it to the Registry I get prometheus::Error::AlreadyReg - which is fine.
I now need some way of getting the previously made MetricVector and using it with .get_metric_with_label_values().inc() or whatever.
I could keep my own registry beside the Registry - but that seems a bit convoluted. I can see there is some concept of a fqdn - but I can't work out how to get at / use it.
Currently we don't have interfaces to iterate registered metrics. However you can do it indirectly by calling gather()..
I agree, this would be a very helpful feature.
We also need this feature as it's not currently possible to get back an already registered collector in a multi-threaded environment (i.e., multiple threads trying to register the same set of metrics and each of them need to get back a handle to increment/decrement the counter). Our code is not ready to use the local-flush feature yet.
Is there any plans to tackle this? If not, I am happy to take a stab at it @lucab @MrCroxx?
Anyone still blocked by this; I found that both https://github.com/prometheus/client_rust and https://github.com/metrics-rs/metrics support this fine.