Crate prometheus_utils
source · [−]Expand description
Utilities for working with Prometheus metrics in Rust
This crate builds on the Promtheus crate to provide API with additional safety guardrails:
- Use
InstrumentedFutureto easily instrument futures with metric updates. - Use
GuardedGaugeto work with gauges using an RAII-style guard that decrements the gauge upon drop. - Use
IntCounterWithLabelsandIntGaugeWithLabelsto produce labeled Prometheus metrics with a type-safe API.
Modules
Macros
Declare an enum intended to be used as a Prometheus label.
Structs
A guard that will automatically increment a GenericCounter when dropped.
A guard that will automatically increment a labeled metric when dropped.
An RAII-style guard for situations where we want to increment a gauge and then ensure that there is always a corresponding decrement.
A Prometheus histogram metric, with labels described by the type L.
An instrumented Future.
A Prometheus integer counter metric, with labels described by the type L.
A Prometheus integer gauge metric, with labels described by the type L.
Collect observations, which are sampled as a Sample.
A sample of the state in Observations.
Windowing is a mechanism for rotating between different observations.
It provides an accessor Windowing::current for the current
observation, and a method Windowing::cycle_windows which makes the
next observation in the ring current, and returns the observation which
was current prior to the call.
Enums
Labels corresponding to the fields in Sample
Traits
An extension trait for GenericCounter to provide methods for incrementing a counter once
an RAII-style guard has been dropped.
An extension trait for GenericGauge to provide methods for temporarily modifying a gauge.
Convert a Future into an instrumented future.
The Labels trait applies to values intended to generate Prometheus labels for a metric.