-
Notifications
You must be signed in to change notification settings - Fork 106
Open
Description
If you create a custom Collector and attach it to a sub registry it appends the name improperly.
#[derive(Debug)]
struct MyCollector {}
impl prometheus_client::collector::Collector for MyCollector {
fn collect<'a>(&'a self) -> Box<dyn Iterator<Item = (std::borrow::Cow<'a, prometheus_client::registry::Descriptor>, prometheus_client::MaybeOwned<'a, Box<dyn prometheus_client::registry::LocalMetric>>)> + 'a> {
let c: Box<dyn prometheus_client::registry::LocalMetric> = Box::new(prometheus_client::metrics::counter::ConstCounter::new(42));
let descriptor = prometheus_client::registry::Descriptor::new(
"my_counter",
"This is my counter",
None,
None,
vec![],
);
Box::new(std::iter::once((std::borrow::Cow::Owned(descriptor), prometheus_client::MaybeOwned::Owned(c))))
}
}
let my_collector = Box::new(MyCollector{});
{
let mut root_registry = <Registry>::with_prefix("root");
let r = root_registry.sub_registry_with_prefix("000");
let r = r.sub_registry_with_prefix("111");
let r = r.sub_registry_with_prefix("222");
r.register_collector(my_collector);
}Results:
# HELP root_root_000_root_000_111_root_000_111_222_my_counter This is my counter.....
# TYPE root_root_000_root_000_111_root_000_111_222_my_counter counter
root_root_000_root_000_111_root_000_111_222_my_counter_total 42
# EOF
Expected:
# HELP root_000_111_222_my_counter This is my counter.....
# TYPE root_000_111_222_my_counter counter
root_000_111_222_my_counter_total 42
# EOF
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels