8 releases

0.3.0 Jul 20, 2020
0.2.0 Oct 19, 2019
0.1.5 Jul 11, 2019
0.1.4 May 28, 2019
0.1.1 Mar 29, 2019

#60 in Profiling

Download history 1/week @ 2021-06-25 3/week @ 2021-07-02 9/week @ 2021-07-16 16/week @ 2021-07-30 12/week @ 2021-08-06 9/week @ 2021-08-13 1/week @ 2021-09-03 2/week @ 2021-09-24 11/week @ 2021-10-01 8/week @ 2021-10-08

51 downloads per month

Apache-2.0 OR MIT

310KB
3.5K 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::{Empty, Pipeline, Spirit};
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

~5.5MB
~106K SLoC