Module mz_ore::metrics::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§
- A
Metric
wrapper that deletes its labels from the vec when it is dropped.
Traits§
- Extension trait for metrics vectors.
- A trait that allows being generic over
MetricVec
s. - An extension trait for types that are valid (or convertible into) prometheus labels: slices/vectors of strings, and
BTreeMap
s.
Type Aliases§
- A
GenericCounter
wrapper that deletes its labels from the vec when it is dropped. - A
GenericGauge
wrapper that deletes its labels from the vec when it is dropped. - A
Histogram
wrapper that deletes its labels from the vec when it is dropped. - The
prometheus
API uses theHashMap
type to pass metrics labels, so we have to allow its usage when calling that API.