Available on (crate features
logging or metrics or tracing or memory-profiling or telemetry-server) and crate feature metrics only.Expand description
Metrics-related functionality.
Foundations provides simple and ergonomic interface to Prometheus metrics:
- Use
metricsmacro to define regular metrics. - Use
report_infofunction to register service information metrics (metrics, whose value is persistent during the service lifetime, e.g. software version). - Use
collectmethod to obtain metrics report programmatically. - Use [telemetry server] to expose a metrics endpoint.
Structs§
- Counter
- A wrapper of
prometheus_client::metrics::counter::Counterwhich does not suffix the name with_total. - Counter
With Exemplar - Open Metrics
Counterwith anExemplarto both measure discrete events and track references to data outside of the metric set. - Family
- A version of
prometheus_client::metrics::family::Familywhich encodes its labels withSerializeinstead ofEncode. - Gauge
- Open Metrics
Gaugeto record current measurements. - Gauge
Guard - Increments a gauge metric when created, and decrements it when dropped.
- Histogram
- Open Metrics
Histogramto measure distributions of discrete events. - Histogram
Builder - A builder suitable for
HistogramandTimeHistogram. - Histogram
Timer - Timer to measure and record the duration of an event.
- Histogram
With Exemplars - Open Metrics
Histogramto 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
Familywhen 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.