Skip to main content

InMemoryMetrics

Struct InMemoryMetrics 

Source
pub struct InMemoryMetrics { /* private fields */ }
Expand description

Process-local monotonic counter registry.

Implementations§

Source§

impl InMemoryMetrics

Source

pub fn new() -> Self

Creates an empty counter registry.

Source

pub fn with_limits(max_entries: usize, max_bytes: usize) -> Self

Creates a registry under explicit limits clamped to public safety ceilings.

Source

pub fn increment(&self, name: &str) -> u64

Saturating-increments a named counter and returns its new value.

Invalid or over-capacity new names return zero and increment the corresponding Self::pressure rejection counter. Existing admitted counters can always be incremented.

Source

pub fn try_increment(&self, name: &str) -> Option<u64>

Attempts to increment a counter under the configured admission bounds.

Source

pub fn snapshot(&self) -> Vec<MetricCounter>

Returns counters ordered by name.

Source

pub fn shared_snapshot(&self) -> MetricSnapshot

Returns an immutable sorted snapshot without cloning counter names.

Retaining this view across an update makes that update clone the map nodes. Each retained generation remains alive until its last snapshot clone is dropped. Consumers must bound retained generations; registry pressure reports the current generation, not all consumer-owned views.

Source

pub fn pressure(&self) -> MetricRegistryPressure

Returns current counter cardinality and retained-memory pressure.

Trait Implementations§

Source§

impl Debug for InMemoryMetrics

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for InMemoryMetrics

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.