multi_input/
multi_input.rs

1//! A sample application sending ad-hoc counter values both to statsd _and_ to stdout.
2
3use dipstick::{Graphite, Input, InputScope, MultiInput, Prefixed, Stream};
4use std::time::Duration;
5
6fn main() {
7    // will output metrics to graphite and to stdout
8    let different_type_metrics = MultiInput::new()
9        .add_target(Graphite::send_to("localhost:2003").expect("Connecting"))
10        .add_target(Stream::write_to_stdout())
11        .metrics();
12
13    // will output metrics twice, once with "both.yeah" prefix and once with "both.ouch" prefix.
14    let same_type_metrics = MultiInput::new()
15        .add_target(Stream::write_to_stderr().named("yeah"))
16        .add_target(Stream::write_to_stderr().named("ouch"))
17        .named("both")
18        .metrics();
19
20    loop {
21        different_type_metrics.counter("counter_a").count(123);
22        same_type_metrics.timer("timer_a").interval_us(2000000);
23        std::thread::sleep(Duration::from_millis(400));
24    }
25}