Struct kumo_prometheus::CounterRegistry

source ·
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>

source

pub fn register(name: &'static str, help: &'static str) -> Self

Register a set of Counters, values that are only allowed to increment.

source

pub fn register_gauge(name: &'static str, help: &'static str) -> Self

Register a set of Gauges, values that are allowed to increase and decrease.

source§

impl<K, V> CounterRegistry<K, V>

source

pub fn get<Q>(&self, key: &Q) -> Option<AtomicCounter>
where K: Borrow<Q>, Q: Hash + Eq + ?Sized,

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.

source

pub fn get_or_create<'a, Q>(&self, key: &'a Q) -> AtomicCounter
where K: Borrow<Q> + From<&'a Q>, Q: Hash + Eq + ?Sized,

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>

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

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>
where K: Send + Sync,

§

impl<K, V> Sync for CounterRegistry<K, V>
where K: Send + Sync,

§

impl<K, V> Unpin for CounterRegistry<K, V>

§

impl<K, V = AtomicCounter> !UnwindSafe for CounterRegistry<K, V>

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> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

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>,

source§

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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more