Sink

Struct Sink 

Source
pub struct Sink<T: Clone + Eq + Hash + Display> { /* private fields */ }
Expand description

Handle for sending metric samples into the receiver.

Sink is cloneable, and can not only send metric samples but can register and deregister metric facets at any time.

Implementations§

Source§

impl<T: Clone + Eq + Hash + Display> Sink<T>

Source

pub fn scoped<'a, S: AsScoped<'a> + ?Sized>(&self, scope: &'a S) -> Sink<T>

Creates a scoped clone of this Sink.

Scoping controls the resulting metric name for any metrics sent by this Sink. For example, you might have a metric called messages_sent.

With scoping, you could have independent versions of the same metric. This is useful for having the same “base” metric name but with broken down values.

Going further with the above example, if you had a server, and listened on multiple addresses, maybe you would have a scoped Sink per listener, and could end up with metrics that look like this:

  • listener.a.messages_sent
  • listener.b.messages_sent
  • listener.c.messages_sent
  • etc

Scopes are also inherited. If you create a scoped Sink from another Sink which is already scoped, the scopes will be merged together using a . as the string separator. This makes it easy to nest scopes. Cloning a scoped Sink, though, will inherit the same scope as the original.

Source

pub fn clock(&self) -> &Clock

Reference to the internal high-speed clock interface.

Source

pub fn update_count(&self, key: T, delta: i64)

Updates the count for a given metric.

Source

pub fn update_gauge(&self, key: T, value: u64)

Updates the value for a given metric.

This can be used either for setting a gauge or updating a value histogram.

Source

pub fn update_timing(&self, key: T, start: u64, end: u64)

Updates the timing histogram for a given metric.

Source

pub fn update_timing_with_count(&self, key: T, start: u64, end: u64, count: u64)

Updates the timing histogram for a given metric, with a count.

Source

pub fn update_value(&self, key: T, value: u64)

Updates the value histogram for a given metric.

Source

pub fn increment(&self, key: T)

Increments the given metric by one.

Source

pub fn decrement(&self, key: T)

Decrements the given metric by one.

Trait Implementations§

Source§

impl<T: Clone + Eq + Hash + Display> Clone for Sink<T>

Source§

fn clone(&self) -> Sink<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl<T> Freeze for Sink<T>

§

impl<T> !RefUnwindSafe for Sink<T>

§

impl<T> Send for Sink<T>
where T: Send,

§

impl<T> Sync for Sink<T>
where T: Send,

§

impl<T> Unpin for Sink<T>

§

impl<T> !UnwindSafe for Sink<T>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

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>,

Source§

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.
Source§

impl<T> Erased for T