[][src]Struct witchcraft_metrics::MetricRegistry

pub struct MetricRegistry { /* fields omitted */ }

A collection of metrics.

Many of the registry's methods take a T: Into<MetricId> rather than just a MetricId. This allows you to pass either a full MetricId or just a &str for more convenient use:

use witchcraft_metrics::{MetricRegistry, MetricId};

let registry = MetricRegistry::new();

let requests_meter = registry.meter("server.requests");
let yak_shavings = registry.counter(MetricId::new("shavings").with_tag("animal", "yak"));

Implementations

impl MetricRegistry[src]

pub fn new() -> MetricRegistry[src]

Creates a new, empty registry.

pub fn set_clock(&mut self, clock: Arc<dyn Clock>)[src]

Sets the Clock used as a time source for new metrics created by the registry.

Defaults to SystemClock.

pub fn clock(&self) -> &Arc<dyn Clock>[src]

Returns a reference to the Clock used as a time source for new metrics created by the registry.

pub fn counter_with<T, F>(&self, id: T, make_counter: F) -> Arc<Counter> where
    T: Into<MetricId>,
    F: FnOnce() -> Counter
[src]

Returns the counter with the specified ID, using make_counter to create it if absent.

Panics

Panics if a metric is registered with the ID that is not a counter.

pub fn counter<T>(&self, id: T) -> Arc<Counter> where
    T: Into<MetricId>, 
[src]

Returns the counter with the specified ID, creating a default instance if absent.

Panics

Panics if a metric is registered with the ID that is not a counter.

pub fn meter_with<T, F>(&self, id: T, make_meter: F) -> Arc<Meter> where
    T: Into<MetricId>,
    F: FnOnce() -> Meter
[src]

Returns the meter with the specified ID, using make_meter to create it if absent.

Panics

Panics if a metric is registered with the ID that is not a meter.

pub fn meter<T>(&self, id: T) -> Arc<Meter> where
    T: Into<MetricId>, 
[src]

Returns the meter with the specified ID, creating a default instance if absent.

Panics

Panics if a metric is registered with the ID that is not a meter.

pub fn gauge_with<T, F, G>(&self, id: T, make_gauge: F) -> Arc<dyn Gauge> where
    T: Into<MetricId>,
    F: FnOnce() -> G,
    G: Gauge
[src]

Returns the gauge with the specified ID, using make_gauge to register a new one if absent.

Panics

Panics if a metric is registered with the ID that is not a gauge.

pub fn gauge<T, G>(&self, id: T, gauge: G) -> Arc<dyn Gauge> where
    T: Into<MetricId>,
    G: Gauge
[src]

Returns the gauge with the specified ID, registering a new one if absent.

Panics

Panics if a metric is registered with the ID that is not a gauge.

pub fn replace_gauge<T, G>(&self, id: T, gauge: G) where
    T: Into<MetricId>,
    G: Gauge
[src]

Adds a gauge to the registry, overwriting the previous metric with that ID if present.

pub fn histogram_with<T, F>(&self, id: T, make_histogram: F) -> Arc<Histogram> where
    T: Into<MetricId>,
    F: FnOnce() -> Histogram
[src]

Returns the histogram with the specified ID, using make_histogram to create it if absent.

Panics

Panics if a metric is registered with the ID that is not a histogram.

pub fn histogram<T>(&self, id: T) -> Arc<Histogram> where
    T: Into<MetricId>, 
[src]

Returns the histogram with the specified ID, creating a default instance if absent.

Panics

Panics if a metric is registered with the ID that is not a histogram.

pub fn timer_with<T, F>(&self, id: T, make_timer: F) -> Arc<Timer> where
    T: Into<MetricId>,
    F: FnOnce() -> Timer
[src]

Returns the timer with the specified ID, using make_timer to create it if absent.

Panics

Panics if a metric is registered with the ID that is not a timer.

pub fn timer<T>(&self, id: T) -> Arc<Timer> where
    T: Into<MetricId>, 
[src]

Returns the timer with the specified ID, creating a default instance if absent.

Panics

Panics if a metric is registered with the ID that is not a timer.

pub fn remove<T>(&self, id: T) -> Option<Metric> where
    T: Into<MetricId>, 
[src]

Removes a metric from the registry, returning it if present.

pub fn metrics(&self) -> Metrics[src]

Returns a snapshot of the metrics in the registry.

Modifications to the registry after this method is called will not affect the state of the returned Metrics.

Trait Implementations

impl Default for MetricRegistry[src]

Auto Trait Implementations

Blanket Implementations

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

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

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

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

impl<T, U> Into<U> for T where
    U: From<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<V, T> VZip<V> for T where
    V: MultiLane<T>,