diff --git a/src/collector.rs b/src/collector.rs index 66270c4..f5c95a0 100644 --- a/src/collector.rs +++ b/src/collector.rs @@ -37,5 +37,5 @@ use crate::encoding::DescriptorEncoder; /// ``` pub trait Collector: std::fmt::Debug + Send + Sync + 'static { /// Once the [`Collector`] is registered, this method is called on each scrape. - fn encode(&self, encoder: DescriptorEncoder) -> Result<(), std::fmt::Error>; + fn encode(&self, encoder: &mut DescriptorEncoder) -> Result<(), std::fmt::Error>; } diff --git a/src/encoding/text.rs b/src/encoding/text.rs index ca44aa9..aaac9cc 100644 --- a/src/encoding/text.rs +++ b/src/encoding/text.rs @@ -1077,7 +1077,7 @@ mod tests { impl crate::collector::Collector for Collector { fn encode( &self, - mut encoder: crate::encoding::DescriptorEncoder, + encoder: &mut crate::encoding::DescriptorEncoder, ) -> Result<(), std::fmt::Error> { let counter = crate::metrics::counter::ConstCounter::new(42u64); let mut metric_encoder = encoder.encode_descriptor( diff --git a/src/registry.rs b/src/registry.rs index 77653e2..2b1a83b 100644 --- a/src/registry.rs +++ b/src/registry.rs @@ -300,9 +300,9 @@ impl Registry { } for collector in self.collectors.iter() { - let descriptor_encoder = + let mut descriptor_encoder = encoder.with_prefix_and_labels(self.prefix.as_ref(), &self.labels); - collector.encode(descriptor_encoder)?; + collector.encode(&mut descriptor_encoder)?; } for registry in self.sub_registries.iter() {