Struct dogstatsd::Client [] [src]

pub struct Client { /* fields omitted */ }

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

Methods

impl Client
[src]

Create a new client from an options struct.

Examples

use dogstatsd::{Client, Options};

  let client = Client::new(Options::default()).unwrap();

Increment a StatsD counter

Examples

use dogstatsd::{Client, Options};


  let client = Client::new(Options::default()).unwrap();
  client.incr("counter", vec!["tag:counter".into()])
      .unwrap_or_else(|e| println!("Encountered error: {}", e));

Decrement a StatsD counter

Examples

use dogstatsd::{Client, Options};


  let client = Client::new(Options::default()).unwrap();
  client.decr("counter", vec!["tag:counter".into()])
      .unwrap_or_else(|e| println!("Encountered error: {}", e));

Time how long it takes for a block of code to execute.

Examples

use dogstatsd::{Client, Options};
  use std::thread;
  use std::time::Duration;


  let client = Client::new(Options::default()).unwrap();
  client.time("timer", vec!["tag:time".into()], || {
      thread::sleep(Duration::from_millis(200))
  }).unwrap_or_else(|e| println!("Encountered error: {}", e))

Send your own timing metric in milliseconds

Examples

use dogstatsd::{Client, Options};


  let client = Client::new(Options::default()).unwrap();
  client.timing("timing", 350, vec!["tag:timing".into()])
      .unwrap_or_else(|e| println!("Encountered error: {}", e));

Report an arbitrary value as a gauge

Examples

use dogstatsd::{Client, Options};

  let client = Client::new(Options::default()).unwrap();
  client.gauge("gauge", "12345", vec!["tag:gauge".into()])
      .unwrap_or_else(|e| println!("Encountered error: {}", e));

Report a value in a histogram

Examples

use dogstatsd::{Client, Options};

  let client = Client::new(Options::default()).unwrap();
  client.histogram("histogram", "67890", vec!["tag:histogram".into()])
      .unwrap_or_else(|e| println!("Encountered error: {}", e));

Report a value in a set

Examples

use dogstatsd::{Client, Options};

  let client = Client::new(Options::default()).unwrap();
  client.set("set", "13579", vec!["tag:set".into()])
      .unwrap_or_else(|e| println!("Encountered error: {}", e));

Send a custom event as a title and a body

Examples

use dogstatsd::{Client, Options};

  let client = Client::new(Options::default()).unwrap();
  client.event("Event Title", "Event Body", vec!["tag:event".into()])
      .unwrap_or_else(|e| println!("Encountered error: {}", e));

Trait Implementations

impl Debug for Client
[src]

Formats the value using the given formatter.

impl PartialEq for Client
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.