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
InstrumentedFuture
to easily instrument futures with metric updates. - Use
GuardedGauge
to work with gauges using an RAII-style guard that decrements the gauge upon drop. - Use
IntCounterWithLabels
andIntGaugeWithLabels
to produce labeled Prometheus metrics with a type-safe API.
Modules§
Macros§
- label_
enum - Declare an enum intended to be used as a Prometheus label.
Structs§
- Deferred
Add - A guard that will automatically increment a
GenericCounter
when dropped. - Deferred
AddWith Labels - A guard that will automatically increment a labeled metric when dropped.
- Generic
Gauge Guard - An RAII-style guard for situations where we want to increment a gauge and then ensure that there is always a corresponding decrement.
- Histogram
With Labels - A Prometheus histogram metric, with labels described by the type
L
. - Instrumented
Future - An instrumented
Future
. - IntCounter
With Labels - A Prometheus integer counter metric, with labels described by the type
L
. - IntGauge
With Labels - A Prometheus integer gauge metric, with labels described by the type
L
. - Observations
- Collect observations, which are sampled as a
Sample
. - Sample
- A sample of the state in
Observations
. - Windowing
Windowing
is a mechanism for rotating between different observations. It provides an accessorWindowing::current
for the current observation, and a methodWindowing::cycle_windows
which makes the next observation in the ring current, and returns the observation which was current prior to the call.
Enums§
- Timing
Bucket - Labels corresponding to the fields in
Sample
Traits§
- Deferred
Counter - An extension trait for
GenericCounter
to provide methods for incrementing a counter once an RAII-style guard has been dropped. - Guarded
Gauge - An extension trait for
GenericGauge
to provide methods for temporarily modifying a gauge. - Into
Instrumented Future - Convert a
Future
into an instrumented future. - Labels
- The
Labels
trait applies to values intended to generate Prometheus labels for a metric.
Type Aliases§
- Gauge
Guard - An RAII-style guard for an
AtomicF64
gauge. - IntGauge
Guard - An RAII-style guard for an
AtomicI64
gauge. - Label
Values - A sequence of values for Prometheus labels