[][src]Crate open_metrics_client

Client library implementing the Open Metrics specification allowing users to natively instrument applications.

Examples

// Create registry and counter and register the latter with the former.
let mut registry = Registry::default();
let counter = Counter::<AtomicU64>::new();
registry.register(
  Descriptor::new("counter", "This is my counter.", "my_counter"),
  counter.clone(),
);

// Record an observation by increasing the counter.
counter.inc();

// Encode all metrics in the registry in the text format.
let mut buffer = vec![];
encode(&mut buffer, &registry).unwrap();

let expected = "# HELP my_counter This is my counter.\n".to_owned() +
               "# TYPE my_counter counter\n" +
               "my_counter_total 1\n" +
               "# EOF\n";
assert_eq!(expected, String::from_utf8(buffer).unwrap());

See examples directory for more.

Modules

counter

Module implementing an Open Metrics counter.

encoding
family

Module implementing an Open Metrics metric family.

gauge

Module implementing an Open Metrics gauge.

histogram

Module implementing an Open Metrics histogram.

registry

Module implementing a metric registry.