Struct MetricsRegistry
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§
§impl MetricsRegistry
impl MetricsRegistry
pub fn new() -> MetricsRegistry
pub fn new() -> MetricsRegistry
Create a new metrics registry with the default in-memory backend
pub fn with_backend(backend: Arc<dyn MetricsBackend>) -> MetricsRegistry
pub fn with_backend(backend: Arc<dyn MetricsBackend>) -> MetricsRegistry
Create a new metrics registry with a custom backend
pub fn register_counter(
&self,
namespace: impl Into<String>,
name: impl Into<String>,
description: impl Into<String>,
) -> Result<CounterHandle, MetricsError>
pub fn register_counter( &self, namespace: impl Into<String>, name: impl Into<String>, description: impl Into<String>, ) -> Result<CounterHandle, MetricsError>
Register a new counter metric
pub fn register_counter_with_labels(
&self,
namespace: impl Into<String>,
name: impl Into<String>,
description: impl Into<String>,
labels: Vec<(String, String)>,
) -> Result<CounterHandle, MetricsError>
pub fn register_counter_with_labels( &self, namespace: impl Into<String>, name: impl Into<String>, description: impl Into<String>, labels: Vec<(String, String)>, ) -> Result<CounterHandle, MetricsError>
Register a new counter metric with labels
pub fn register_gauge(
&self,
namespace: impl Into<String>,
name: impl Into<String>,
description: impl Into<String>,
unit: impl Into<String>,
) -> Result<GaugeHandle, MetricsError>
pub fn register_gauge( &self, namespace: impl Into<String>, name: impl Into<String>, description: impl Into<String>, unit: impl Into<String>, ) -> Result<GaugeHandle, MetricsError>
Register a new gauge metric
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)>,
) -> Result<GaugeHandle, MetricsError>
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)>, ) -> Result<GaugeHandle, MetricsError>
Register a new gauge metric with labels
pub fn register_histogram(
&self,
namespace: impl Into<String>,
name: impl Into<String>,
description: impl Into<String>,
unit: impl Into<String>,
buckets: Vec<f64>,
) -> Result<HistogramHandle, MetricsError>
pub fn register_histogram( &self, namespace: impl Into<String>, name: impl Into<String>, description: impl Into<String>, unit: impl Into<String>, buckets: Vec<f64>, ) -> Result<HistogramHandle, MetricsError>
Register a new histogram metric
pub fn get_metric(&self, id: &MetricId) -> Result<Metric, MetricsError>
pub fn get_metric(&self, id: &MetricId) -> Result<Metric, MetricsError>
Get a metric by ID
pub fn contains_metric(&self, id: &MetricId) -> bool
pub fn contains_metric(&self, id: &MetricId) -> bool
Check if a metric exists
pub 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
pub fn get_all_counters(&self) -> Vec<Metric>
pub fn get_all_counters(&self) -> Vec<Metric>
Get all counters
pub fn get_all_gauges(&self) -> Vec<Metric>
pub fn get_all_gauges(&self) -> Vec<Metric>
Get all gauges
pub fn metric_count(&self) -> usize
pub fn metric_count(&self) -> usize
Get the total number of metrics
Trait Implementations§
§impl Debug for MetricsRegistry
impl Debug for MetricsRegistry
§impl Default for MetricsRegistry
impl Default for MetricsRegistry
§fn default() -> MetricsRegistry
fn default() -> MetricsRegistry
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for MetricsRegistry
impl !RefUnwindSafe for MetricsRegistry
impl Send for MetricsRegistry
impl Sync for MetricsRegistry
impl Unpin for MetricsRegistry
impl UnsafeUnpin for MetricsRegistry
impl !UnwindSafe for MetricsRegistry
Blanket Implementations§
§impl<T> AppLifecycle for Twhere
T: ?Sized,
impl<T> AppLifecycle for Twhere
T: ?Sized,
§fn on_start(&mut self, ctx: &mut dyn AppContext)
fn on_start(&mut self, ctx: &mut dyn AppContext)
Called once after the backend is up but before the first
update. Apps install their theme / fonts here.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
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Converts
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Converts
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Converts
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Converts
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian().§impl<F, T, S> SimdInto<T, S> for Fwhere
T: SimdFrom<F, S>,
S: Simd,
impl<F, T, S> SimdInto<T, S> for Fwhere
T: SimdFrom<F, S>,
S: Simd,
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.