Struct dogstatsd::Client
[−]
[src]
pub struct Client { /* fields omitted */ }
The client struct that handles sending metrics to the Dogstatsd server.
Methods
impl Client
[src]
fn new(options: Options) -> Result<Self, DogstatsdError>
[src]
Create a new client from an options struct.
Examples
use dogstatsd::{Client, Options}; let client = Client::new(Options::default()).unwrap();
fn incr<'a, I, S, T>(&self, stat: S, tags: I) -> DogstatsdResult where
I: IntoIterator<Item = T>,
S: Into<Cow<'a, str>>,
T: AsRef<str>,
[src]
I: IntoIterator<Item = T>,
S: Into<Cow<'a, str>>,
T: AsRef<str>,
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));
fn decr<'a, I, S, T>(&self, stat: S, tags: I) -> DogstatsdResult where
I: IntoIterator<Item = T>,
S: Into<Cow<'a, str>>,
T: AsRef<str>,
[src]
I: IntoIterator<Item = T>,
S: Into<Cow<'a, str>>,
T: AsRef<str>,
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));
fn time<'a, F, I, S, T>(&self, stat: S, tags: I, block: F) -> DogstatsdResult where
F: FnOnce(),
I: IntoIterator<Item = T>,
S: Into<Cow<'a, str>>,
T: AsRef<str>,
[src]
F: FnOnce(),
I: IntoIterator<Item = T>,
S: Into<Cow<'a, str>>,
T: AsRef<str>,
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))
fn timing<'a, I, S, T>(&self, stat: S, ms: i64, tags: I) -> DogstatsdResult where
I: IntoIterator<Item = T>,
S: Into<Cow<'a, str>>,
T: AsRef<str>,
[src]
I: IntoIterator<Item = T>,
S: Into<Cow<'a, str>>,
T: AsRef<str>,
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));
fn gauge<'a, I, S, T>(&self, stat: S, val: S, tags: I) -> DogstatsdResult where
I: IntoIterator<Item = T>,
S: Into<Cow<'a, str>>,
T: AsRef<str>,
[src]
I: IntoIterator<Item = T>,
S: Into<Cow<'a, str>>,
T: AsRef<str>,
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));
fn histogram<'a, I, S, T>(&self, stat: S, val: S, tags: I) -> DogstatsdResult where
I: IntoIterator<Item = T>,
S: Into<Cow<'a, str>>,
T: AsRef<str>,
[src]
I: IntoIterator<Item = T>,
S: Into<Cow<'a, str>>,
T: AsRef<str>,
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));
fn set<'a, I, S, T>(&self, stat: S, val: S, tags: I) -> DogstatsdResult where
I: IntoIterator<Item = T>,
S: Into<Cow<'a, str>>,
T: AsRef<str>,
[src]
I: IntoIterator<Item = T>,
S: Into<Cow<'a, str>>,
T: AsRef<str>,
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));
fn service_check<'a, I, S, T>(
&self,
stat: S,
val: ServiceStatus,
tags: I,
options: Option<ServiceCheckOptions>
) -> DogstatsdResult where
I: IntoIterator<Item = T>,
S: Into<Cow<'a, str>>,
T: AsRef<str>,
[src]
&self,
stat: S,
val: ServiceStatus,
tags: I,
options: Option<ServiceCheckOptions>
) -> DogstatsdResult where
I: IntoIterator<Item = T>,
S: Into<Cow<'a, str>>,
T: AsRef<str>,
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));
fn event<'a, I, S, T>(&self, title: S, text: S, tags: I) -> DogstatsdResult where
I: IntoIterator<Item = T>,
S: Into<Cow<'a, str>>,
T: AsRef<str>,
[src]
I: IntoIterator<Item = T>,
S: Into<Cow<'a, str>>,
T: AsRef<str>,
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));