Trait Metrics

Source
pub trait Metrics:
    Clone
    + Send
    + Sync
    + 'static {
    // Required methods
    fn label(&self) -> String;
    fn with_label(&self, label: &str) -> Self;
    fn register<N: Into<String>, H: Into<String>>(
        &self,
        name: N,
        help: H,
        metric: impl Metric,
    );
    fn encode(&self) -> String;

    // Provided method
    fn scoped_label(&self, label: &str) -> String { ... }
}
Expand description

Interface to register and encode metrics.

Required Methods§

Source

fn label(&self) -> String

Get the current label of the context.

Source

fn with_label(&self, label: &str) -> Self

Create a new instance of Metrics with the given label appended to the end of the current Metrics label.

This is commonly used to create a nested context for register.

It is not permitted for any implementation to use METRICS_PREFIX as the start of a label (reserved for metrics for the runtime).

Source

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

Register a metric with the runtime.

Any registered metric will include (as a prefix) the label of the current context.

Source

fn encode(&self) -> String

Encode all metrics into a buffer.

Provided Methods§

Source

fn scoped_label(&self, label: &str) -> String

Prefix the given label with the current context’s label.

Unlike with_label, this method does not create a new context.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl Metrics for commonware_runtime::deterministic::Context

Source§

impl Metrics for commonware_runtime::tokio::Context