tikv / rust-prometheus

Prometheus instrumentation library for Rust applications
Apache License 2.0
1.04k stars 182 forks source link

Gathering empty MetricFamily #508

Closed alexandrebrg closed 6 months ago

alexandrebrg commented 6 months ago

Hello :wave: !

Is your feature request related to a problem? Please describe.

We are currently writing a Prometheus Exporter using your library. It exposes a lot of metrics, and we cannot find a way to reliably & easily see all metrics available. We'd like to have it so we can expose it in our project (e.g. a METRICS.md file), it would be useful for us and for users of the exporter.

Describe the solution you'd like

After digging, I found out that gathering metrics with Prometheus::gather() filters out all metrics that are empty. And that this behaviour is for all registries.

Proposed solution would be to have a function or method that can fetch all metrics (name, labels, description & type) registered in a Registry, without filtering whether it's empty or not. It could introduce a new struct similiar to MetricFamily where it hasn't the ability to get or set the metric in it. This solution would introduce ability to users to work with registered metrics "raw".

Describe alternatives you've considered

Additional context

I'd be happy to contribute ;D

alexandrebrg commented 6 months ago

Closing as it was due to the encoder and to lazy loading, not to the gather method itself.