Module delete_on_drop

Source
Available on crate feature metrics only.
Expand description

Support for metrics that get removed from their corresponding metrics vector when dropped.

§Ownership & life times

This kind of data type is realized by a struct that retains ownership of the labels used to create the spin-off metric. The created metric follows these rules:

  • When passing references, the metric must not outlive the references to the labels used to create it: A 'static slice of static strings means the metric is allowed to live for the 'static lifetime as well.
  • Metrics created from references to dynamically constructed labels can only live as long as those labels do.
  • When using owned data (an extension over what Prometheus allows, which only lets you use references to refer to labels), the created metric is also allowed to live for 'static.

Structs§

DeleteOnDropMetric
A Metric wrapper that deletes its labels from the vec when it is dropped.

Traits§

MetricVecExt
Extension trait for metrics vectors.
MetricVec_
A trait that allows being generic over MetricVecs.
PromLabelsExt
An extension trait for types that are valid (or convertible into) prometheus labels: slices/vectors of strings, and BTreeMaps.

Type Aliases§

DeleteOnDropCounter
A GenericCounter wrapper that deletes its labels from the vec when it is dropped.
DeleteOnDropGauge
A GenericGauge wrapper that deletes its labels from the vec when it is dropped.
DeleteOnDropHistogram
A Histogram wrapper that deletes its labels from the vec when it is dropped.
PromLabelMap 🔒
The prometheus API uses the HashMap type to pass metrics labels, so we have to allow its usage when calling that API.