statsd_sampling/statsd_sampling.rs
1//! A sample application sending ad-hoc counter values both to statsd _and_ to stdout.
2
3use dipstick::*;
4use std::time::Duration;
5
6fn main() {
7 let metrics = Statsd::send_to("localhost:8125")
8 .expect("Connected")
9 .sampled(Sampling::Random(0.2))
10 .named("my_app")
11 .metrics();
12
13 let counter = metrics.counter("counter_a");
14
15 loop {
16 for i in 1..11 {
17 counter.count(i);
18 }
19 std::thread::sleep(Duration::from_millis(3000));
20 }
21}