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 |
#231 in Profiling
27 downloads per month
315KB
3.5K
SLoC
Spirit-hyper
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
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
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
~7.5MB
~140K SLoC