Expand description

Trait that encompasses all other traits for sending metrics.

If you wish to use StatsdClient with a generic type or place a StatsdClient instance behind a pointer (such as a Box) this will allow you to reference all the implemented methods for recording metrics, while using a single trait. An example of this is shown below.

use std::time::Duration;
use cadence::{MetricClient, StatsdClient, NopMetricSink};

let client: Box<dyn MetricClient> = Box::new(StatsdClient::from_sink(
    "prefix", NopMetricSink));

client.count("some.counter", 1).unwrap();
client.time("some.timer", 42).unwrap();
client.time("some.timer", Duration::from_millis(42)).unwrap();
client.gauge("some.gauge", 8).unwrap();
client.meter("some.meter", 13).unwrap();
client.histogram("some.histogram", 4).unwrap();
client.histogram("some.histogram", Duration::from_nanos(4)).unwrap();
client.distribution("some.distribution", 4).unwrap();
client.set("some.set", 5).unwrap();

Implementors