simple_sink/
simple-sink.rs1use cadence::prelude::*;
15use cadence::{StatsdClient, UdpMetricSink, DEFAULT_PORT};
16use std::net::UdpSocket;
17use std::time::Duration;
18
19fn main() {
20 let sock = UdpSocket::bind("0.0.0.0:0").unwrap();
21 let sink = UdpMetricSink::from(("localhost", DEFAULT_PORT), sock).unwrap();
22 let client = StatsdClient::from_sink("example.prefix", sink);
23
24 client.count("example.counter", 1).unwrap();
25 client.gauge("example.gauge", 5).unwrap();
26 client.gauge("example.gauge", 5.0).unwrap();
27 client.time("example.timer", 32).unwrap();
28 client.time("example.timer", Duration::from_millis(32)).unwrap();
29 client.histogram("example.histogram", 22).unwrap();
30 client.histogram("example.histogram", Duration::from_nanos(22)).unwrap();
31 client.histogram("example.histogram", 22.0).unwrap();
32 client.distribution("example.distribution", 33).unwrap();
33 client.distribution("example.distribution", 33.0).unwrap();
34 client.meter("example.meter", 8).unwrap();
35 client.set("example.set", 44).unwrap();
36}