dipstick/examples/clopwizard.rs

42 lines
1.0 KiB
Rust
Raw Normal View History

2018-12-18 19:17:12 +00:00
//! A dropwizard-like configuration using three buckets
//! aggregating one, five and fifteen minutes of data.
2018-06-22 19:32:07 +00:00
extern crate dipstick;
use dipstick::*;
use std::thread::sleep;
2019-04-09 11:55:15 +00:00
use std::time::Duration;
2018-06-22 19:32:07 +00:00
2019-04-09 11:55:15 +00:00
metrics! {
2018-06-22 19:32:07 +00:00
APP = "application" => {
pub COUNTER: Counter = "counter";
}
}
fn main() {
2018-10-26 01:20:47 +00:00
let one_minute = AtomicBucket::new();
2018-06-22 19:32:07 +00:00
one_minute.flush_every(Duration::from_secs(60));
2018-10-26 01:20:47 +00:00
let five_minutes = AtomicBucket::new();
2018-06-22 19:32:07 +00:00
five_minutes.flush_every(Duration::from_secs(300));
2018-10-26 01:20:47 +00:00
let fifteen_minutes = AtomicBucket::new();
2018-06-22 19:32:07 +00:00
fifteen_minutes.flush_every(Duration::from_secs(900));
2018-06-26 20:41:05 +00:00
let all_buckets = MultiInputScope::new()
.add_target(one_minute)
.add_target(five_minutes)
.add_target(fifteen_minutes)
.named("machine_name");
2018-06-22 19:32:07 +00:00
// send application metrics to aggregator
Proxy::default().target(all_buckets);
AtomicBucket::default_drain(Stream::to_stdout());
AtomicBucket::default_stats(stats_all);
2018-06-22 19:32:07 +00:00
loop {
COUNTER.count(17);
sleep(Duration::from_secs(3));
}
}