Trait prometheus_client::collector::Collector
source · pub trait Collector: Debug + Send + Sync + 'static {
// Required method
fn collect<'a>(
&'a self
) -> Box<dyn Iterator<Item = (Cow<'a, Descriptor>, MaybeOwned<'a, Box<dyn LocalMetric>>)> + 'a>;
}
Expand description
The Collector
abstraction allows users to provide additional metrics and
their description on each scrape.
An example use-case is an exporter that retrieves a set of operating system metrics ad-hoc on each scrape.
Register a Collector
with a Registry
via
Registry::register_collector
.
Required Methods§
sourcefn collect<'a>(
&'a self
) -> Box<dyn Iterator<Item = (Cow<'a, Descriptor>, MaybeOwned<'a, Box<dyn LocalMetric>>)> + 'a>
fn collect<'a>( &'a self ) -> Box<dyn Iterator<Item = (Cow<'a, Descriptor>, MaybeOwned<'a, Box<dyn LocalMetric>>)> + 'a>
Once the Collector
is registered, this method is called on each scrape.
Note that the return type allows you to either return owned (convenient) or borrowed (performant) descriptions and metrics.