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§
Sourcefn with_label(&self, label: &str) -> Self
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).
Provided Methods§
Sourcefn scoped_label(&self, label: &str) -> String
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.