Struct metrics_process::Collector
source · pub struct Collector { /* private fields */ }
Expand description
Prometheus style process metrics collector
Implementations§
source§impl Collector
impl Collector
sourcepub fn prefix(self, prefix: impl Into<String>) -> Self
pub fn prefix(self, prefix: impl Into<String>) -> Self
Add an prefix that is prepended to metric keys.
Examples
let collector = Collector::default().prefix("my_prefix_");
sourcepub fn describe(&self)
pub fn describe(&self)
Describe available metrics through describe_gauge!
macro of metrics
crate.
Example
// Recorder must be initialized prior to describe.
let builder = PrometheusBuilder::new();
builder.install().expect("failed to install recorder/exporter");
let collector = Collector::default();
// Describe collector
collector.describe();
sourcepub fn collect(&self)
pub fn collect(&self)
Collect metrics and record through gauge!
macro of metrics
crate.
Example
// Recorder must be initialized prior to describe.
let builder = PrometheusBuilder::new();
builder.install().expect("failed to install recorder/exporter");
let collector = Collector::default();
collector.describe();
// Collect metrics
collector.collect();