pub struct Registry { /* private fields */ }Expand description
A thread-safe registry for storing metrics by name.
Stores one Arc-wrapped instance per unique metric name for each enabled
metric type. Repeated lookups for the same name return the same Arc
(pointer equality holds). Only metric types enabled via Cargo features are
compiled in; attempting to call a method for a disabled type will result in
a compile-time error.
Cache-line aligned to prevent false sharing in concurrent environments.
Implementations§
Source§impl Registry
impl Registry
Sourcepub fn get_or_create_counter(&self, name: &str) -> Arc<Counter>
pub fn get_or_create_counter(&self, name: &str) -> Arc<Counter>
Get or create a counter by name.
Requires the count feature.
Sourcepub fn get_or_create_gauge(&self, name: &str) -> Arc<Gauge>
pub fn get_or_create_gauge(&self, name: &str) -> Arc<Gauge>
Get or create a gauge by name.
Requires the gauge feature.
Sourcepub fn get_or_create_timer(&self, name: &str) -> Arc<Timer>
pub fn get_or_create_timer(&self, name: &str) -> Arc<Timer>
Get or create a timer by name.
Requires the timer feature.
Sourcepub fn counter_names(&self) -> Vec<String>
pub fn counter_names(&self) -> Vec<String>
Get all registered counter names. Requires the count feature.
Sourcepub fn gauge_names(&self) -> Vec<String>
pub fn gauge_names(&self) -> Vec<String>
Get all registered gauge names. Requires the gauge feature.
Sourcepub fn timer_names(&self) -> Vec<String>
pub fn timer_names(&self) -> Vec<String>
Get all registered timer names. Requires the timer feature.
Sourcepub fn metric_count(&self) -> usize
pub fn metric_count(&self) -> usize
Get total number of registered metrics across all enabled metric types.