[][src]Struct metrics::Sink

pub struct Sink { /* fields omitted */ }

Handle for sending metric samples.

Methods

impl Sink[src]

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

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.

pub fn now(&self) -> u64[src]

Gets the current time, in nanoseconds, from the internal high-speed clock.

pub fn record_count<N: Into<MetricName>>(&mut self, name: N, value: u64)[src]

Records a value for a counter identified by the given name.

pub fn record_gauge<N: Into<MetricName>>(&mut self, name: N, value: i64)[src]

Records the value for a gauge identified by the given name.

pub fn record_timing<N: Into<MetricName>, V: Delta>(
    &mut self,
    name: N,
    start: V,
    end: V
)
[src]

Records the value for a timing histogram identified by the given name.

Both the start and end times must be supplied, but any values that implement Delta can be used which allows for raw values from quanta::Clock to be used, or measurements from [Instant::now].

pub fn record_value<N: Into<MetricName>>(&mut self, name: N, value: u64)[src]

Records the value for a value histogram identified by the given name.

pub fn counter<N: Into<MetricName>>(&mut self, name: N) -> Counter[src]

Creates a handle to the given counter.

This handle can be embedded into an existing type and used to directly update the underlying counter. It is merely a proxy, so multiple handles to the same counter can be held and used.

pub fn gauge<N: Into<MetricName>>(&mut self, name: N) -> Gauge[src]

Creates a handle to the given gauge.

This handle can be embedded into an existing type and used to directly update the underlying gauge. It is merely a proxy, so multiple handles to the same gauge can be held and used.

pub fn histogram<N: Into<MetricName>>(&mut self, name: N) -> Histogram[src]

Creates a handle to the given histogram.

This handle can be embedded into an existing type and used to directly update the underlying histogram. It is merely a proxy, so multiple handles to the same histogram can be held and used.

Trait Implementations

impl Clone for Sink[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

Auto Trait Implementations

impl Send for Sink

impl Sync for Sink

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> Erased for T