pub struct InMemoryMetrics { /* private fields */ }Expand description
Process-local monotonic counter registry.
Implementations§
Source§impl InMemoryMetrics
impl InMemoryMetrics
Sourcepub fn with_limits(max_entries: usize, max_bytes: usize) -> Self
pub fn with_limits(max_entries: usize, max_bytes: usize) -> Self
Creates a registry under explicit limits clamped to public safety ceilings.
Sourcepub fn increment(&self, name: &str) -> u64
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.
Sourcepub fn try_increment(&self, name: &str) -> Option<u64>
pub fn try_increment(&self, name: &str) -> Option<u64>
Attempts to increment a counter under the configured admission bounds.
Sourcepub fn snapshot(&self) -> Vec<MetricCounter>
pub fn snapshot(&self) -> Vec<MetricCounter>
Returns counters ordered by name.
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.
Sourcepub fn pressure(&self) -> MetricRegistryPressure
pub fn pressure(&self) -> MetricRegistryPressure
Returns current counter cardinality and retained-memory pressure.