Skip to main content

MetricBuilder

Struct MetricBuilder 

Source
pub struct MetricBuilder<'s> { /* private fields */ }
Expand description

Builder for creating metrics with labels.

Implementations§

Source§

impl<'r> MetricBuilder<'r>

Source

pub fn new(registry: &'r dyn MetricsRegistry) -> Self

Create a new builder for a metric backed by a MetricsRegistry.

Source

pub fn add_label<K, V>(self, key: K, value: V) -> Self
where K: Into<Cow<'static, str>>, V: Into<Cow<'static, str>>,

Add a label to the metric. Labels might not be unique, and its up to consumers of this data to resolve such cases.

Source

pub fn add_labels<I, L>(self, labels: I) -> Self
where I: IntoIterator<Item = L>, L: Into<Label>,

Adds multiple labels to the metric. Labels might not be unique, and its up to consumers of this data to resolve such cases.

Source

pub fn counter(self, name: impl Into<Cow<'static, str>>) -> Counter

Creates a new Counter with the given name, registering it with the backend.

Source

pub fn histogram(self, name: impl Into<Cow<'static, str>>) -> Histogram

Creates a new Histogram with the given name, registering it with the backend.

Source

pub fn timer(self, name: impl Into<Cow<'static, str>>) -> Timer

Creates a new Timer with the given name, registering it with the backend.

Source

pub fn gauge(self, name: impl Into<Cow<'static, str>>) -> Gauge

Creates a new Gauge with the given name, registering it with the backend.

Auto Trait Implementations§

§

impl<'s> Freeze for MetricBuilder<'s>

§

impl<'s> !RefUnwindSafe for MetricBuilder<'s>

§

impl<'s> Send for MetricBuilder<'s>

§

impl<'s> Sync for MetricBuilder<'s>

§

impl<'s> Unpin for MetricBuilder<'s>

§

impl<'s> UnsafeUnpin for MetricBuilder<'s>

§

impl<'s> !UnwindSafe for MetricBuilder<'s>

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

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.