[−][src]Struct dogstatsd::Client
The client struct that handles sending metrics to the Dogstatsd server.
Methods
impl Client
[src]
pub 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();
pub 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));
pub 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));
pub fn count<'a, I, S, T>(
&self,
stat: S,
count: i64,
tags: I
) -> DogstatsdResult where
I: IntoIterator<Item = T>,
S: Into<Cow<'a, str>>,
T: AsRef<str>,
[src]
&self,
stat: S,
count: i64,
tags: I
) -> DogstatsdResult where
I: IntoIterator<Item = T>,
S: Into<Cow<'a, str>>,
T: AsRef<str>,
Make an arbitrary change to a StatsD counter
Examples
use dogstatsd::{Client, Options}; let client = Client::new(Options::default()).unwrap(); client.count("counter", 42, &["tag:counter"]) .unwrap_or_else(|e| println!("Encountered error: {}", e));
pub 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]
&self,
stat: S,
tags: I,
block: F
) -> DogstatsdResult where
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))
pub 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));
pub fn gauge<'a, I, S, SS, T>(
&self,
stat: S,
val: SS,
tags: I
) -> DogstatsdResult where
I: IntoIterator<Item = T>,
S: Into<Cow<'a, str>>,
SS: Into<Cow<'a, str>>,
T: AsRef<str>,
[src]
&self,
stat: S,
val: SS,
tags: I
) -> DogstatsdResult where
I: IntoIterator<Item = T>,
S: Into<Cow<'a, str>>,
SS: 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));
pub fn histogram<'a, I, S, SS, T>(
&self,
stat: S,
val: SS,
tags: I
) -> DogstatsdResult where
I: IntoIterator<Item = T>,
S: Into<Cow<'a, str>>,
SS: Into<Cow<'a, str>>,
T: AsRef<str>,
[src]
&self,
stat: S,
val: SS,
tags: I
) -> DogstatsdResult where
I: IntoIterator<Item = T>,
S: Into<Cow<'a, str>>,
SS: 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));
pub fn distribution<'a, I, S, SS, T>(
&self,
stat: S,
val: SS,
tags: I
) -> DogstatsdResult where
I: IntoIterator<Item = T>,
S: Into<Cow<'a, str>>,
SS: Into<Cow<'a, str>>,
T: AsRef<str>,
[src]
&self,
stat: S,
val: SS,
tags: I
) -> DogstatsdResult where
I: IntoIterator<Item = T>,
S: Into<Cow<'a, str>>,
SS: Into<Cow<'a, str>>,
T: AsRef<str>,
Report a value in a distribution
Examples
use dogstatsd::{Client, Options}; let client = Client::new(Options::default()).unwrap(); client.distribution("distribution", "67890", &["tag:distribution"]) .unwrap_or_else(|e| println!("Encountered error: {}", e));
pub fn set<'a, I, S, SS, T>(&self, stat: S, val: SS, tags: I) -> DogstatsdResult where
I: IntoIterator<Item = T>,
S: Into<Cow<'a, str>>,
SS: Into<Cow<'a, str>>,
T: AsRef<str>,
[src]
I: IntoIterator<Item = T>,
S: Into<Cow<'a, str>>,
SS: 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));
pub 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));
pub fn event<'a, I, S, SS, T>(
&self,
title: S,
text: SS,
tags: I
) -> DogstatsdResult where
I: IntoIterator<Item = T>,
S: Into<Cow<'a, str>>,
SS: Into<Cow<'a, str>>,
T: AsRef<str>,
[src]
&self,
title: S,
text: SS,
tags: I
) -> DogstatsdResult where
I: IntoIterator<Item = T>,
S: Into<Cow<'a, str>>,
SS: 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));
Trait Implementations
impl PartialEq<Client> for Client
[src]
fn eq(&self, other: &Self) -> bool
[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl Debug for Client
[src]
Auto Trait Implementations
impl Unpin for Client
impl Sync for Client
impl Send for Client
impl UnwindSafe for Client
impl RefUnwindSafe for Client
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,