Crate prometheus_utils[][src]

Expand description

Utilities for working with Prometheus metrics in Rust

This crate builds on the Promtheus crate to provide API with additional safety guardrails:



Declare an enum intended to be used as a Prometheus label.


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.

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.


Labels corresponding to the fields in Sample


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.

Type Definitions

An RAII-style guard for an AtomicF64 gauge.

An RAII-style guard for an AtomicI64 gauge.

A sequence of values for Prometheus labels