pub struct CounterRegistry<K, V: AtomicCounterEntry = AtomicCounter> { /* private fields */ }
Expand description
Either a Counter or Gauge with a specific name, where there can be multiple labelled counter instances.
CounterRegistry has a PruningCounterRegistry variant which will drop unreferenced counter instances when they fall out of scope.
The key type K must be created via the label_key! macro provided by this crate. It allows making type-safe keys and resolving counter instances without making extraneous copies of the keys.
CounterRegistry implements the StreamingCollector trait which allows for efficient streaming serialization of its set of counters in either text or json format.
Implementations§
source§impl<K: Clone + Send + Sync + MetricLabel + 'static, V: AtomicCounterEntry + 'static> CounterRegistry<K, V>
impl<K: Clone + Send + Sync + MetricLabel + 'static, V: AtomicCounterEntry + 'static> CounterRegistry<K, V>
source§impl<K, V> CounterRegistry<K, V>
impl<K, V> CounterRegistry<K, V>
sourcepub fn get<Q>(&self, key: &Q) -> Option<AtomicCounter>
pub fn get<Q>(&self, key: &Q) -> Option<AtomicCounter>
Resolve an already-existing counter for the given key, or None if there either has never been such a value, or if it was pruned.
sourcepub fn get_or_create<'a, Q>(&self, key: &'a Q) -> AtomicCounter
pub fn get_or_create<'a, Q>(&self, key: &'a Q) -> AtomicCounter
Resolve an already-existing counter for the given key, creating a new one if it didn’t already exist, or was previously pruned.
Trait Implementations§
source§impl<K, V: AtomicCounterEntry> Clone for CounterRegistry<K, V>
impl<K, V: AtomicCounterEntry> Clone for CounterRegistry<K, V>
Auto Trait Implementations§
impl<K, V> Freeze for CounterRegistry<K, V>
impl<K, V = AtomicCounter> !RefUnwindSafe for CounterRegistry<K, V>
impl<K, V> Send for CounterRegistry<K, V>
impl<K, V> Sync for CounterRegistry<K, V>
impl<K, V> Unpin for CounterRegistry<K, V>
impl<K, V = AtomicCounter> !UnwindSafe for CounterRegistry<K, V>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)