Available on (crate features
logging
or metrics
or telemetry
or tracing
or memory-profiling
) and crate feature metrics
only.Expand description
Metrics-related functionality.
Foundations provides simple and ergonomic interface to Prometheus metrics:
- Use
metrics
macro to define regular metrics. - Use
report_info
function to register service information metrics (metrics, whose value is persistent during the service lifetime, e.g. software version). - Use
collect
method to obtain metrics report programmatically. - Use [telemetry server] to expose a metrics endpoint.
Structs§
- Counter
- A wrapper of
prometheus_client::metrics::counter::Counter
which does not suffix the name with_total
. - Counter
With Exemplar - Open Metrics
Counter
with anExemplar
to both measure discrete events and track references to data outside of the metric set. - Family
- A wrapper around
prometheus_client::metrics::family::Family
which encodes its labels withSerialize
instead ofEncode
. - Gauge
- Open Metrics
Gauge
to record current measurements. - Gauge
Guard - Increments a gauge metric when created, and decrements it when dropped.
- Histogram
- Open Metrics
Histogram
to measure distributions of discrete events. - Histogram
Builder - A builder suitable for
Histogram
andTimeHistogram
. - Histogram
Timer - Timer to measure and record the duration of an event.
- Histogram
With Exemplars - Open Metrics
Histogram
to both measure distributions of discrete events. and track references to data outside of the metric set. - Range
Gauge - Prometheus metric based on a gauge, but additionally records the minimum and maximum values of that gauge since the last recorded value was taken.
- Time
Histogram - A faster, lock-free histogram for tracking time.
Traits§
- Extra
Producer - Describes something that can expand prometheus metrics but appending them in a text format to a provided buffer.
- Info
Metric - Describes an info metric.
- Metric
Constructor - A constructor for creating new metrics in a
Family
when callingFamily::get_or_create
. Such constructor is provided viaFamily::new_with_constructor
.
Functions§
- add_
extra_ producer - Adds an ExtraProducer that runs whenever Prometheus metrics are scraped. The producer appends metrics into a provided buffer to make them available.
- collect
- Collects all metrics in Prometheus text format.
- report_
info - Registers an info metric, i.e. a gauge metric whose value is always
1
, set at init time.
Attribute Macros§
- info_
metric - A macro that allows to define a Prometheus info metric.
- metrics
- A macro that allows to define Prometheus metrics.