Struct metrics_prometheus::storage::Immutable
source · pub struct Immutable { /* private fields */ }
Expand description
Snapshot of a mutable::Storage
, that is not capable of registering
metrics in a prometheus::Registry
on the fly, but still allowing to
change their help
description on the fly, once they were registered in
the mutable::Storage
before snapshot.
In comparison with a metrics::Registry
, this immutable Storage
provides much less overhead of accessing an already registered metric (just
a simple HashMap
lookup), however, is not capable of registering new
metrics on the fly.
Implementations§
source§impl Storage
impl Storage
sourcepub fn describe<M>(&self, name: &str, description: String)where
M: Bundled,
<M as Bundled>::Bundle: Bundle,
Self: Get<Collection<<M as Bundled>::Bundle>>,
pub fn describe<M>(&self, name: &str, description: String)where
M: Bundled,
<M as Bundled>::Bundle: Bundle,
Self: Get<Collection<<M as Bundled>::Bundle>>,
Changes the help
description of the prometheus
M
etric
identified by its name
. No-op if this immutable Storage
doesn’t
contain it.
Accepts only the following prometheus
M
etrics:
prometheus::IntCounter
,prometheus::IntCounterVec
prometheus::Gauge
,prometheus::GaugeVec
prometheus::Histogram
,prometheus::HistogramVec
Intended to be used in metrics::Recorder::describe_counter()
,
metrics::Recorder::describe_gauge()
and
metrics::Recorder::describe_histogram()
implementations.
sourcepub fn get_metric<M>(&self, key: &Key) -> Option<Result<Metric<M>, Error>>where
M: Bundled,
<M as Bundled>::Bundle: Bundle<Single = M>,
Self: Get<Collection<<M as Bundled>::Bundle>>,
pub fn get_metric<M>(&self, key: &Key) -> Option<Result<Metric<M>, Error>>where
M: Bundled,
<M as Bundled>::Bundle: Bundle<Single = M>,
Self: Get<Collection<<M as Bundled>::Bundle>>,
Returns a prometheus
M
etric stored in this immutable Storage
and identified by the provided metrics::Key
.
Accepts only the following prometheus
metrics:
Intended to be used in metrics::Recorder::register_counter()
,
metrics::Recorder::register_gauge()
and
metrics::Recorder::register_histogram()
implementations.
Errors
If the identified prometheus
M
etric doesn’t comply with the
labeling of the provided metrics::Key
.