Struct vise::MetricsCollection

source ·
pub struct MetricsCollection<F = fn(_: &MetricGroupDescriptor) -> bool> { /* private fields */ }
Expand description

Configures collection of registered metrics.

§Examples

See Registry docs for examples of usage.

Implementations§

source§

impl MetricsCollection

source

pub fn lazy() -> Self

Specifies that metrics should be lazily exported.

By default, Global metrics are eagerly collected into a Registry; i.e., metrics will get exported even if they were never modified by the app / library logic. This is usually fine (e.g., this allows getting all metrics metadata on the first scrape), but sometimes you may want to export only metrics touched by the app / library logic. E.g., you have a single app binary that exposes different sets of metrics depending on configuration, and exporting all metrics is confusing and/or unacceptably bloats exported data size.

lazy() solves this issue. It will configure the created Registry so that Global metrics are only exported after they are touched by the app / library logic. Beware that this includes being touched by an eager MetricsCollection (only metrics actually included into the collection are touched).

source

pub fn filter<F>(self, filter_fn: F) -> MetricsCollection<F>

Configures a filtering predicate for this collection. Only Metrics with a descriptor satisfying this will be collected.

source§

impl<F: FnMut(&MetricGroupDescriptor) -> bool> MetricsCollection<F>

source

pub fn collect(self) -> Registry

Creates a registry with all registered Global metrics and Collectors. If a filtering predicate was provided, only metrics satisfying this function will be collected.

Trait Implementations§

source§

impl<F: Debug> Debug for MetricsCollection<F>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for MetricsCollection

source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<F> Freeze for MetricsCollection<F>
where F: Freeze,

§

impl<F> RefUnwindSafe for MetricsCollection<F>
where F: RefUnwindSafe,

§

impl<F> Send for MetricsCollection<F>
where F: Send,

§

impl<F> Sync for MetricsCollection<F>
where F: Sync,

§

impl<F> Unpin for MetricsCollection<F>
where F: Unpin,

§

impl<F> UnwindSafe for MetricsCollection<F>
where F: UnwindSafe,

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.