pub struct MetricsRegistry { /* private fields */ }Expand description
Registry of all kernel metrics. Lock-free on the hot path.
Counters use AtomicU64, gauges use AtomicI64, and histograms
use fixed-bucket atomic counters. DashMap provides concurrent
access to the registry without global locks.
Implementations§
Source§impl MetricsRegistry
impl MetricsRegistry
Sourcepub fn with_builtins() -> Self
pub fn with_builtins() -> Self
Create a registry pre-populated with built-in kernel metrics.
Sourcepub fn counter_inc(&self, name: &str)
pub fn counter_inc(&self, name: &str)
Increment a counter by 1.
Sourcepub fn counter_add(&self, name: &str, value: u64)
pub fn counter_add(&self, name: &str, value: u64)
Add a value to a counter.
Sourcepub fn counter_get(&self, name: &str) -> u64
pub fn counter_get(&self, name: &str) -> u64
Get the current value of a counter.
Sourcepub fn histogram_record(&self, name: &str, value: f64)
pub fn histogram_record(&self, name: &str, value: f64)
Record a value in a histogram.
If the histogram does not exist, it is created with default buckets.
Sourcepub fn histogram_register(&self, name: &str, boundaries: &[f64])
pub fn histogram_register(&self, name: &str, boundaries: &[f64])
Register a histogram with custom bucket boundaries.
Sourcepub fn histogram_percentile(&self, name: &str, p: f64) -> Option<f64>
pub fn histogram_percentile(&self, name: &str, p: f64) -> Option<f64>
Get a percentile estimate from a histogram.
Sourcepub fn histogram_buckets(&self, name: &str) -> Option<Vec<(f64, u64)>>
pub fn histogram_buckets(&self, name: &str) -> Option<Vec<(f64, u64)>>
Get histogram bucket snapshot.
Sourcepub fn snapshot_all(&self) -> Vec<MetricSnapshot>
pub fn snapshot_all(&self) -> Vec<MetricSnapshot>
Take a snapshot of all metrics.
Sourcepub fn list_names(&self) -> Vec<String>
pub fn list_names(&self) -> Vec<String>
List all metric names.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for MetricsRegistry
impl Freeze for MetricsRegistry
impl Send for MetricsRegistry
impl Sync for MetricsRegistry
impl Unpin for MetricsRegistry
impl UnsafeUnpin for MetricsRegistry
impl UnwindSafe for MetricsRegistry
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
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more