pub struct MetricsCore { /* private fields */ }Expand description
Main metrics interface - the core of everything
Implementations§
Source§impl MetricsCore
impl MetricsCore
Sourcepub fn counter(&self, name: &str) -> Arc<Counter>
pub fn counter(&self, name: &str) -> Arc<Counter>
Get or create a counter by name. Requires the count feature.
name is accepted as &str — string literals ("counter") and
owned/borrowed runtime names both work. The first lookup for a given
name allocates a String key inside the registry; subsequent lookups
of the same name reuse the cached Arc and perform no allocations.
Sourcepub fn counter_with(&self, name: &str, labels: &LabelSet) -> Arc<Counter>
pub fn counter_with(&self, name: &str, labels: &LabelSet) -> Arc<Counter>
Get or create a labeled counter. Requires the count feature.
Routes to the cardinality overflow sink when the cap is full; use
Self::try_counter_with to receive an explicit error instead.
Sourcepub fn try_counter_with(
&self,
name: &str,
labels: &LabelSet,
) -> Result<Arc<Counter>>
pub fn try_counter_with( &self, name: &str, labels: &LabelSet, ) -> Result<Arc<Counter>>
Labeled counter returning Err(CardinalityExceeded) when the cap is
full. Requires the count feature.
Sourcepub fn gauge(&self, name: &str) -> Arc<Gauge>
pub fn gauge(&self, name: &str) -> Arc<Gauge>
Get or create a gauge by name. Requires the gauge feature.
name is accepted as &str — see Self::counter for allocation
semantics.
Sourcepub fn gauge_with(&self, name: &str, labels: &LabelSet) -> Arc<Gauge>
pub fn gauge_with(&self, name: &str, labels: &LabelSet) -> Arc<Gauge>
Get or create a labeled gauge. Requires the gauge feature.
Sourcepub fn try_gauge_with(
&self,
name: &str,
labels: &LabelSet,
) -> Result<Arc<Gauge>>
pub fn try_gauge_with( &self, name: &str, labels: &LabelSet, ) -> Result<Arc<Gauge>>
Labeled gauge returning Err(CardinalityExceeded) when the cap is
full. Requires the gauge feature.
Sourcepub fn timer(&self, name: &str) -> Arc<Timer>
pub fn timer(&self, name: &str) -> Arc<Timer>
Get or create a timer by name. Requires the timer feature.
name is accepted as &str — see Self::counter for allocation
semantics.
Sourcepub fn timer_with(&self, name: &str, labels: &LabelSet) -> Arc<Timer>
pub fn timer_with(&self, name: &str, labels: &LabelSet) -> Arc<Timer>
Get or create a labeled timer. Requires the timer feature.
Sourcepub fn try_timer_with(
&self,
name: &str,
labels: &LabelSet,
) -> Result<Arc<Timer>>
pub fn try_timer_with( &self, name: &str, labels: &LabelSet, ) -> Result<Arc<Timer>>
Labeled timer returning Err(CardinalityExceeded) when the cap is
full. Requires the timer feature.
Sourcepub fn time<T>(&self, name: &str, f: impl FnOnce() -> T) -> T
pub fn time<T>(&self, name: &str, f: impl FnOnce() -> T) -> T
Time a synchronous closure and record the elapsed duration.
Requires the timer feature.
Sourcepub fn system(&self) -> &SystemHealth
pub fn system(&self) -> &SystemHealth
Get system health interface