Trait metriken_core::Metric
source · pub trait Metric: Send + Sync + 'static {
// Required methods
fn as_any(&self) -> Option<&dyn Any>;
fn value(&self) -> Option<Value<'_>>;
// Provided method
fn is_enabled(&self) -> bool { ... }
}Expand description
Global interface to a metric.
Most use of metrics should use the directly declared constants.
Required Methods§
sourcefn as_any(&self) -> Option<&dyn Any>
fn as_any(&self) -> Option<&dyn Any>
Get the current metric as an Any instance. This is meant to allow
custom processing for known metric types.
sourcefn value(&self) -> Option<Value<'_>>
fn value(&self) -> Option<Value<'_>>
Get the value of the current metric, should it be enabled.
Note to Implementors
If your metric’s value does not correspond to one of the variants of
Value then return Value::Other and metric consumers can use
as_any to specifically handle your metric.
Provided Methods§
sourcefn is_enabled(&self) -> bool
fn is_enabled(&self) -> bool
Indicate whether this metric has been set up.
Generally, if this returns false then the other methods on this
trait should return None.