Struct MetricsRegistry

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

Central registry for metrics in the KhoraEngine

This registry provides a high-level API for metrics management and serves as the main entry point for the metrics system. It handles metric registration, updates, and queries while providing type safety and convenient helper methods.

Implementations§

Source§

impl MetricsRegistry

Source

pub fn new() -> Self

Create a new metrics registry with the default in-memory backend

Source

pub fn with_backend(backend: Arc<dyn MetricsBackend>) -> Self

Create a new metrics registry with a custom backend

Source

pub fn register_counter( &self, namespace: impl Into<String>, name: impl Into<String>, description: impl Into<String>, ) -> MetricsResult<CounterHandle>

Register a new counter metric

Source

pub fn register_counter_with_labels( &self, namespace: impl Into<String>, name: impl Into<String>, description: impl Into<String>, labels: Vec<(String, String)>, ) -> MetricsResult<CounterHandle>

Register a new counter metric with labels

Source

pub fn register_gauge( &self, namespace: impl Into<String>, name: impl Into<String>, description: impl Into<String>, unit: impl Into<String>, ) -> MetricsResult<GaugeHandle>

Register a new gauge metric

Source

pub fn register_gauge_with_labels( &self, namespace: impl Into<String>, name: impl Into<String>, description: impl Into<String>, unit: impl Into<String>, labels: Vec<(String, String)>, ) -> MetricsResult<GaugeHandle>

Register a new gauge metric with labels

Source

pub fn register_histogram( &self, namespace: impl Into<String>, name: impl Into<String>, description: impl Into<String>, unit: impl Into<String>, buckets: Vec<f64>, ) -> MetricsResult<HistogramHandle>

Register a new histogram metric

Source

pub fn get_metric(&self, id: &MetricId) -> MetricsResult<Metric>

Get a metric by ID

Source

pub fn contains_metric(&self, id: &MetricId) -> bool

Check if a metric exists

Source

pub fn get_namespace_metrics(&self, namespace: &str) -> Vec<Metric>

Get all metrics in a namespace

Source

pub fn get_all_counters(&self) -> Vec<Metric>

Get all counters

Source

pub fn get_all_gauges(&self) -> Vec<Metric>

Get all gauges

Source

pub fn metric_count(&self) -> usize

Get the total number of metrics

Source

pub fn clear_all(&self) -> MetricsResult<()>

Clear all metrics

Source

pub fn backend(&self) -> &Arc<dyn MetricsBackend>

Get direct access to the backend (for advanced operations)

Trait Implementations§

Source§

impl Debug for MetricsRegistry

Source§

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

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

impl Default for MetricsRegistry

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