prometheus / client_rust

Prometheus / OpenMetrics client library in Rust
Apache License 2.0
469 stars 73 forks source link

Allow root registry creation with prefix AND label(s) #146

Open popadi opened 1 year ago

popadi commented 1 year ago

As the title says, is it okay to add a constructor (with_prefix_and_labels; please suggest a better name eventually) that allows the creation of a base/root registry with a prefix and some default labels? Or maybe a way to allow the mutation of the labels of a registry.

I have a bunch of counters coming from from processes running on different hosts and I'd like to have them labeled with about 2-3 base/identification labels to be able to query them in my dashboards properly. Due to some restrictions I am not able to inject these labels directly via kubernetes on Prometheus scrape. At the same time, I see no reason TO NOT allow the creation of a registry with default labels.

This is a question related a bit to the previously posted issue (https://github.com/prometheus/client_rust/issues/144) for which I submitted a pull request (https://github.com/prometheus/client_rust/pull/145).

mxinden commented 1 year ago

No objections to adding Registry::with_prefix_and_labels. Contribution welcome.