cloudflare / foundations

Cloudflare's Rust service foundations library.
https://blog.cloudflare.com/introducing-foundations-our-open-source-rust-service-foundation-library
BSD 3-Clause "New" or "Revised" License
1.25k stars 51 forks source link

Construct metrics registry with default() when name_in_metrics is empty #36

Closed djhworld closed 6 months ago

djhworld commented 6 months ago

This adds a clause to use Registry::default() if name_in_metrics is empty

At the moment using the with_prefix method, the metrics that get rendered ends up looking like this: _my_metric because prefix is Option https://github.com/prometheus/client_rust/blob/master/src/registry.rs#L62

Using Registry::default() will set prefix to None so that metrics get rendered without the leading underscore.