Skip to main content

Metrics

Trait Metrics 

Source
pub trait Metrics: Supervisor {
    // Required methods
    fn register<N: Into<String>, H: Into<String>, M: Metric>(
        &self,
        name: N,
        help: H,
        metric: M,
    ) -> Registered<M>;
    fn encode(&self) -> String;
}
Expand description

Interface to register and encode metrics.

Required Methods§

Source

fn register<N: Into<String>, H: Into<String>, M: Metric>( &self, name: N, help: H, metric: M, ) -> Registered<M>

Register a metric with the runtime.

Any registered metric includes the current context label as its name prefix and the current context attributes as Prometheus labels. See Supervisor for the identity model and examples.

The returned telemetry::metrics::Registered value must be retained for as long as the metric should remain exposed. Dropping the returned handle unregisters the metric immediately.

Re-registering the same metric key (same prefixed name and attributes) returns another handle to the existing metric when the concrete metric type matches. Registering the same key with a different metric type panics.

Names must start with [a-zA-Z] and contain only [a-zA-Z0-9_].

Source

fn encode(&self) -> String

Encode all metrics into a buffer.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl Metrics for commonware_runtime::deterministic::Context

Source§

impl Metrics for commonware_runtime::tokio::Context