#metrics #configuration #spirit #dipstick

spirit-dipstick

Automatic configuration of dipstick backends

6 releases

✓ Uses Rust 2018 edition

0.1.5 Jul 11, 2019
0.1.4 May 28, 2019
0.1.3 Apr 17, 2019
0.1.1 Mar 29, 2019

#23 in Profiling

Download history 42/week @ 2019-03-28 58/week @ 2019-04-04 32/week @ 2019-04-11 18/week @ 2019-04-18 23/week @ 2019-04-25 25/week @ 2019-05-02 36/week @ 2019-05-09 8/week @ 2019-05-16 24/week @ 2019-05-23 49/week @ 2019-05-30 6/week @ 2019-06-06 11/week @ 2019-06-13 27/week @ 2019-06-20 64/week @ 2019-06-27 76/week @ 2019-07-04

132 downloads per month

Apache-2.0 OR MIT

233KB
3K SLoC

Spirit-hyper

Travis Build Status

A helper to auto-configure dipstick backend. It is part of the spirit system.

See the docs and the examples.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.


lib.rs:

Configuration support for the [dipstick] metrics library.

This provides a configuration [Fragment] for the [spirit] family of libraries. It configures the „backend“ part of the library ‒ the part that sends the metrics somewhere, like to statsd or a file.

Examples

use dipstick::{stats_all, InputScope};
use serde::Deserialize;
use spirit::prelude::*;
use spirit_dipstick::{Config as MetricsConfig, Monitor};

#[derive(Debug, Default, Deserialize)]
struct Cfg {
    metrics: MetricsConfig,
}

impl Cfg {
   fn metrics(&self) -> &MetricsConfig {
        &self.metrics
   }
}

const CFG: &str = r#"
[metrics]
prefix = "example" # If omitted, the name of the application is used
flush-period = "5s"  # Dump metric statistics every 5 seconds
backends = [
    { type = "file", filename = "/tmp/metrics.txt" },
    { type = "stdout" },
]
"#;

fn main() {
   let root = Monitor::new();

    Spirit::<Empty, Cfg>::new()
       .config_defaults(CFG)
       .with(
           Pipeline::new("metrics")
               .extract_cfg(Cfg::metrics)
               .install(root.installer(stats_all)),
       )
       .run(move |_| {
           let counter = root.counter("looped");
           counter.count(1);
           Ok(())
       });
}

Dependencies

~20MB
~451K SLoC