Struct dogstatsd::Client [] [src]

pub struct Client { /* fields omitted */ }

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

Methods

impl Client
[src]

[src]

Create a new client from an options struct.

Examples

use dogstatsd::{Client, Options};

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

[src]

Increment a StatsD counter

Examples

use dogstatsd::{Client, Options};

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

[src]

Decrement a StatsD counter

Examples

use dogstatsd::{Client, Options};

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

[src]

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", &["tag:time"], || {
      thread::sleep(Duration::from_millis(200))
  }).unwrap_or_else(|e| println!("Encountered error: {}", e))

[src]

Send your own timing metric in milliseconds

Examples

use dogstatsd::{Client, Options};

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

[src]

Report an arbitrary value as a gauge

Examples

use dogstatsd::{Client, Options};

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

[src]

Report a value in a histogram

Examples

use dogstatsd::{Client, Options};

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

[src]

Report a value in a set

Examples

use dogstatsd::{Client, Options};

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

[src]

Report the status of a service

Examples

use dogstatsd::{Client, Options, ServiceStatus, ServiceCheckOptions};

  let client = Client::new(Options::default()).unwrap();
  client.service_check("redis.can_connect", ServiceStatus::OK, &["tag:service"], None)
      .unwrap_or_else(|e| println!("Encountered error: {}", e));

  let options = ServiceCheckOptions {
    hostname: Some("my-host.localhost"),
    ..Default::default()
  };
  client.service_check("redis.can_connect", ServiceStatus::OK, &["tag:service"], Some(options))
      .unwrap_or_else(|e| println!("Encountered error: {}", e));

  let all_options = ServiceCheckOptions {
    hostname: Some("my-host.localhost"),
    timestamp: Some(1510326433),
    message: Some("Message about the check or service")
  };
  client.service_check("redis.can_connect", ServiceStatus::OK, &["tag:service"], Some(all_options))
      .unwrap_or_else(|e| println!("Encountered error: {}", e));

[src]

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", &["tag:event"])
      .unwrap_or_else(|e| println!("Encountered error: {}", e));

Trait Implementations

impl Debug for Client
[src]

[src]

Formats the value using the given formatter.

impl PartialEq for Client
[src]

[src]

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

1.0.0
[src]

This method tests for !=.