Module metrics

Source
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.
CounterWithExemplar
Open Metrics Counter with an Exemplar 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 with Serialize instead of Encode.
Gauge
Open Metrics Gauge to record current measurements.
GaugeGuard
Increments a gauge metric when created, and decrements it when dropped.
Histogram
Open Metrics Histogram to measure distributions of discrete events.
HistogramBuilder
A builder suitable for Histogram and TimeHistogram.
HistogramTimer
Timer to measure and record the duration of an event.
HistogramWithExemplars
Open Metrics Histogram to both measure distributions of discrete events. and track references to data outside of the metric set.
RangeGauge
Prometheus metric based on a gauge, but additionally records the minimum and maximum values of that gauge since the last recorded value was taken.
TimeHistogram
A faster, lock-free histogram for tracking time.

Traits§

ExtraProducer
Describes something that can expand prometheus metrics but appending them in a text format to a provided buffer.
InfoMetric
Describes an info metric.
MetricConstructor
A constructor for creating new metrics in a Family when calling Family::get_or_create. Such constructor is provided via Family::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.