Crate prometrics

Source
Expand description

Client library for exposing prometheus metrics.

Currently this crate only support text format for exposing metrics.

§Examples

use prometrics::default_gatherer;
use prometrics::metrics::{CounterBuilder, GaugeBuilder};

let counter = CounterBuilder::new("count")
    .default_registry()
    .finish()
    .unwrap();
let gauge = GaugeBuilder::new("gauge")
    .label("foo", "bar")
    .default_registry()
    .finish()
    .unwrap();

 counter.increment();
 gauge.set(12.3);

 let metrics = default_gatherer().lock().unwrap().gather();
 assert_eq!(
    metrics.to_text(),
    format!("{}\n{}\n{}\n{}\n",
            "# TYPE count counter",
            "count 1",
            "# TYPE gauge gauge",
            "gauge{foo=\"bar\"} 12.3"));

§References

Modules§

bucket
Bucket for histogram metric.
label
Metric label.
metric
Metric.
metrics
Concrete metrics.
quantile
Summary quantile.
timestamp
Unix timestamp.

Structs§

Error
This crate specific error type.
Gatherer
Metrics gatherer.
Registry
Collector registry.

Enums§

ErrorKind
The list of the possible error kinds

Traits§

Collect
This trait allows for collecting metrics.

Functions§

default_gatherer
Returns the global default Gatherer.
default_registry
Returns the global default Registry.

Type Aliases§

Result
This crate specific Result type.