Crate dogstatsd [] [src]

A Rust client for interacting with Dogstatsd

Dogstatsd is a custom StatsD implementation by DataDog for sending metrics and events to their system. Through this client you can report any type of metric you want, tag it, and enjoy your custom metrics.


Build an options struct and create a client:

use dogstatsd::{Client, Options};

// Binds to a udp socket on an available ephemeral port on for
// transmitting, and sends to, the default dogstatsd
// address.
let default_options = Options::default();
let default_client = Client::new(default_options).unwrap();

// Binds to for transmitting and sends to, with a
// namespace of "analytics".
let custom_options = Options::new("", "", "analytics");
let custom_client = Client::new(custom_options).unwrap();

Start sending metrics:

use dogstatsd::{Client, Options};

let client = Client::new(Options::default()).unwrap();
let tags = &["env:production"];

// Increment a counter
client.incr("my_counter", tags).unwrap();

// Decrement a counter
client.decr("my_counter", tags).unwrap();

// Time a block of code (reports in ms)
client.time("my_time", tags, || {
    // Some time consuming code

// Report your own timing in ms
client.timing("my_timing", 500, tags).unwrap();

// Report an arbitrary value (a gauge)
client.gauge("my_gauge", "12345", tags).unwrap();

// Report a sample of a histogram
client.histogram("my_histogram", "67890", tags).unwrap();

// Report a member of a set
client.set("my_set", "13579", tags).unwrap();

// Send a custom event
client.event("My Custom Event Title", "My Custom Event Body", tags).unwrap();



The client struct that handles sending metrics to the Dogstatsd server.


The struct that represents the options available for the Dogstatsd client.


Struct for adding optional pieces to a service check



Represents the different states a service can be in

Type Definitions


A type alias for returning a unit type or an error