pub struct Pipeline { /* private fields */ }

Implementations§

source§

impl Pipeline

source

pub fn new() -> Pipeline

source

pub fn set_max_udp_size(&mut self, max_udp_size: usize)

Set max UDP packet size

use datadog_statsd::client::Pipeline;

let mut pipe = Pipeline::new();
pipe.set_max_udp_size(128);
source

pub fn incr(&mut self, metric: &str)

Increment a metric by 1

use datadog_statsd::client::Pipeline;

let mut pipe = Pipeline::new();
// Increment a given metric by 1.
pipe.incr("metric.completed");

This modifies a counter with an effective sampling rate of 1.0.

source

pub fn decr(&mut self, metric: &str)

Decrement a metric by -1

use datadog_statsd::client::Pipeline;

let mut pipe = Pipeline::new();
// Decrement a given metric by 1
pipe.decr("metric.completed");

This modifies a counter with an effective sampling rate of 1.0.

source

pub fn count(&mut self, metric: &str, value: f64)

Modify a counter by value.

Will increment or decrement a counter by value with a sampling rate of 1.0.

use datadog_statsd::client::Pipeline;

let mut pipe = Pipeline::new();
// Increment by 12
pipe.count("metric.completed", 12.0);
source

pub fn sampled_count(&mut self, metric: &str, value: f64, rate: f64)

Modify a counter by value only x% of the time.

Will increment or decrement a counter by value with a custom sampling rate.

use datadog_statsd::client::Pipeline;

let mut pipe = Pipeline::new();
// Increment by 4 50% of the time.
pipe.sampled_count("metric.completed", 4.0, 0.5);
source

pub fn gauge(&mut self, metric: &str, value: f64)

Set a gauge value.

use datadog_statsd::client::Pipeline;

let mut pipe = Pipeline::new();
// set a gauge to 9001
pipe.gauge("power_level.observed", 9001.0);
source

pub fn timer(&mut self, metric: &str, value: f64)

Send a timer value.

The value is expected to be in ms.

use datadog_statsd::client::Pipeline;

let mut pipe = Pipeline::new();
// pass a duration value
pipe.timer("response.duration", 10.123);
source

pub fn time<F>(&mut self, metric: &str, callable: F)
where F: FnOnce(),

Time a block of code.

The passed closure will be timed and executed. The block’s duration will be sent as a metric.

use datadog_statsd::client::Pipeline;

let mut pipe = Pipeline::new();
// pass a duration value
pipe.time("response.duration", || {
  // Your code here.
});
source

pub fn histogram(&mut self, metric: &str, value: f64)

Send a histogram value.

use datadog_statsd::client::Pipeline;

let mut pipe = Pipeline::new();
// pass response size value
pipe.histogram("response.size", 128.0);
source

pub fn send(&mut self, client: &Client)

Send data along the UDP socket.

Trait Implementations§

source§

impl Default for Pipeline

source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.