[−][src]Struct witchcraft_metrics::MetricRegistry
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]
T: Into<MetricId>,
F: FnOnce() -> Counter,
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]
T: Into<MetricId>,
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]
T: Into<MetricId>,
F: FnOnce() -> Meter,
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]
T: Into<MetricId>,
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]
T: Into<MetricId>,
F: FnOnce() -> G,
G: Gauge,
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]
T: Into<MetricId>,
G: Gauge,
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]
T: Into<MetricId>,
G: Gauge,
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]
T: Into<MetricId>,
F: FnOnce() -> Histogram,
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]
T: Into<MetricId>,
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]
T: Into<MetricId>,
F: FnOnce() -> Timer,
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]
T: Into<MetricId>,
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]
T: Into<MetricId>,
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
impl !RefUnwindSafe for MetricRegistry
impl Send for MetricRegistry
impl Sync for MetricRegistry
impl Unpin for MetricRegistry
impl !UnwindSafe for MetricRegistry
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,