#prometheus #metrics

prometrics

Client library for exposing prometheus metrics

14 releases

Uses old Rust 2015

0.1.13 Apr 18, 2020
0.1.12 Aug 18, 2019
0.1.11 Apr 30, 2018
0.1.10 Mar 23, 2018
0.1.2 Oct 22, 2017

#12 in #prometheus

Download history 117/week @ 2021-01-05 113/week @ 2021-01-12 127/week @ 2021-01-19 118/week @ 2021-01-26 105/week @ 2021-02-02 163/week @ 2021-02-09 153/week @ 2021-02-16 133/week @ 2021-02-23 151/week @ 2021-03-02 168/week @ 2021-03-09 113/week @ 2021-03-16 156/week @ 2021-03-23 177/week @ 2021-03-30 135/week @ 2021-04-06 159/week @ 2021-04-13 205/week @ 2021-04-20

486 downloads per month
Used in 23 crates (13 directly)

MIT license

99KB
2.5K SLoC

prometrics

Crates.io: prometrics Documentation Build Status Code Coverage License: MIT

Rust client library for exposing prometheus metrics.

Documentation

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"));

Benchmark

$ uname -a
Linux DESKTOP 4.4.0-43-Microsoft #1-Microsoft Wed Dec 31 14:42:53 PST 2014 x86_64 x86_64 x86_64 GNU/Linux

$ lscpu | grep 'Model name:'
Model name:            Intel(R) Core(TM) i7-7660U CPU @ 2.50GHz

$ cargo +nightly bench
test counter_add_float       ... bench:          10 ns/iter (+/- 0)
test counter_add_round_float ... bench:           4 ns/iter (+/- 0)
test counter_add_u64         ... bench:           4 ns/iter (+/- 0)
test counter_increment       ... bench:           4 ns/iter (+/- 0)
test gauge_set               ... bench:           4 ns/iter (+/- 0)
test histogram_observe       ... bench:          18 ns/iter (+/- 0)
test summary_observe         ... bench:         481 ns/iter (+/- 21)

test result: ok. 0 passed; 0 failed; 0 ignored; 7 measured; 0 filtered out

References

Dependencies

~0.4–1MB
~23K SLoC