#metrics #statsd #graphite #timer #monitoring

dipstick

A fast and modular metrics library decoupling app instrumentation from reporting backend. Similar to popular logging frameworks, but with counters and timers. Can be configured for combined outputs (log + statsd), random sampling, local aggregation of metrics, recurrent background publication, etc

42 releases

0.7.1 Jan 13, 2019
0.6.11 Jun 8, 2018
0.6.5 Jan 16, 2018
0.5.1 Dec 13, 2017
0.4.11 Nov 29, 2017

#2 in Visualization

Download history 719/week @ 2018-11-09 583/week @ 2018-11-16 561/week @ 2018-11-23 510/week @ 2018-11-30 630/week @ 2018-12-07 383/week @ 2018-12-14 142/week @ 2018-12-21 58/week @ 2018-12-28 197/week @ 2019-01-04 197/week @ 2019-01-11 109/week @ 2019-01-18 78/week @ 2019-01-25 89/week @ 2019-02-01 96/week @ 2019-02-08 109/week @ 2019-02-15

1,829 downloads per month
Used in 1 crate

MIT/Apache

158KB
3.5K SLoC

crates.io docs.rs Build Status

dipstick a dipstick picture

A one-stop shop metrics library for Rust applications with lots of features,
minimal impact on applications and a choice of output to downstream systems.

Features

Dipstick is a toolkit to help all sorts of application collect and send out metrics. As such, it needs a bit of set up to suit one's needs. Skimming through the handbook and many examples should help you get an idea of the possible configurations.

In short, dipstick-enabled apps can:

  • Send metrics to console, log, statsd, graphite or prometheus (one or many)
  • Locally aggregate the count, sum, mean, min, max and rate of metric values
  • Publish aggregated metrics, on schedule or programmatically
  • Customize output statistics and formatting
  • Define global or scoped (e.g. per request) metrics
  • Statistically sample metrics (statsd)
  • Choose between sync or async operation
  • Choose between buffered or immediate output
  • Switch between metric backends at runtime

For convenience, dipstick builds on stable Rust with minimal, feature-gated dependencies. Performance, safety and ergonomy are also prime concerns.

Non-goals

Dipstick's focus is on metrics collection (input) and forwarding (output). Although it will happily aggregate base statistics, for the sake of simplicity and performance Dipstick will not

  • plot graphs
  • send alerts
  • track histograms

These are all best done by downstream timeseries visualization and monitoring tools.

Show me the code!

Here's a basic aggregating & auto-publish counter metric:

let bucket = AtomicBucket::new();
bucket.set_drain(Stream::to_stdout());
bucket.flush_every(std::time::Duration::from_secs(3));
let counter = bucket.counter("counter_a");
counter.count(8);

Persistent apps wanting to declare static metrics will prefer using the metrics! macro:

metrics! { METRICS = "my_app" => {
        pub COUNTER: Counter = "my_counter";
    }
}

fn main() {
    METRICS.set_target(Graphite::send_to("localhost:2003").unwrap().input());
    COUNTER.count(32);
}

For sample applications see the examples. For documentation see the handbook.

To use Dipstick in your project, add the following line to your Cargo.toml in the [dependencies] section:

dipstick = "0.7.1"

TODO / Missing / Weak points

  • Prometheus support is still primitive (read untested). Only the push gateway approach is supported for now.
  • No backend for "pull" metrics yet. Should at least provide tiny-http listener capability.
  • No quick integration feature with common frameworks (Actix, etc.) is provided yet.
  • Thread Local buckets could be nice.
  • "Rolling" aggregators would be nice for pull metrics. Current bucket impl resets after flush.

License

Dipstick is licensed under the terms of the Apache 2.0 and MIT license.

Dependencies

~1.5MB
~24K SLoC

  • build build.rs