Trait metriken::Metric

source ·
pub trait Metric: Send + Sync + 'static {
    // Required methods
    fn as_any(&self) -> Option<&(dyn Any + 'static)>;
    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§

source

fn as_any(&self) -> Option<&(dyn Any + 'static)>

Get the current metric as an Any instance. This is meant to allow custom processing for known metric types.

source

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§

source

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.

Implementors§