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
impl MetricsRegistry
Sourcepub fn with_backend(backend: Arc<dyn MetricsBackend>) -> Self
pub fn with_backend(backend: Arc<dyn MetricsBackend>) -> Self
Create a new metrics registry with a custom backend
Sourcepub fn register_counter(
&self,
namespace: impl Into<String>,
name: impl Into<String>,
description: impl Into<String>,
) -> MetricsResult<CounterHandle>
pub fn register_counter( &self, namespace: impl Into<String>, name: impl Into<String>, description: impl Into<String>, ) -> MetricsResult<CounterHandle>
Register a new counter metric
Sourcepub fn register_counter_with_labels(
&self,
namespace: impl Into<String>,
name: impl Into<String>,
description: impl Into<String>,
labels: Vec<(String, String)>,
) -> MetricsResult<CounterHandle>
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
Sourcepub fn register_gauge(
&self,
namespace: impl Into<String>,
name: impl Into<String>,
description: impl Into<String>,
unit: impl Into<String>,
) -> MetricsResult<GaugeHandle>
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
Sourcepub 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>
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
Sourcepub 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>
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
Sourcepub fn get_metric(&self, id: &MetricId) -> MetricsResult<Metric>
pub fn get_metric(&self, id: &MetricId) -> MetricsResult<Metric>
Get a metric by ID
Sourcepub fn contains_metric(&self, id: &MetricId) -> bool
pub fn contains_metric(&self, id: &MetricId) -> bool
Check if a metric exists
Sourcepub fn get_namespace_metrics(&self, namespace: &str) -> Vec<Metric>
pub fn get_namespace_metrics(&self, namespace: &str) -> Vec<Metric>
Get all metrics in a namespace
Sourcepub fn get_all_counters(&self) -> Vec<Metric>
pub fn get_all_counters(&self) -> Vec<Metric>
Get all counters
Sourcepub fn get_all_gauges(&self) -> Vec<Metric>
pub fn get_all_gauges(&self) -> Vec<Metric>
Get all gauges
Sourcepub fn metric_count(&self) -> usize
pub fn metric_count(&self) -> usize
Get the total number of metrics
Sourcepub fn backend(&self) -> &Arc<dyn MetricsBackend>
pub fn backend(&self) -> &Arc<dyn MetricsBackend>
Get direct access to the backend (for advanced operations)
Trait Implementations§
Source§impl Debug for MetricsRegistry
impl Debug for MetricsRegistry
Auto Trait Implementations§
impl Freeze for MetricsRegistry
impl !RefUnwindSafe for MetricsRegistry
impl Send for MetricsRegistry
impl Sync for MetricsRegistry
impl Unpin 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