Expand description
Metric types, collection, and Prometheus encoders for foundations.
This crate provides counters, gauges, histograms, metric families, and
encoders for OpenMetrics text and Prometheus protobuf formats. It uses
foundations-metrics-registry for the process-global registry and protobuf
data model.
foundations currently re-exports these APIs from
foundations::telemetry::metrics. Libraries can depend on this crate
directly, to maximize compatibility with foundations’ versions. However,
binaries which use foundations should still use the top-level foundations
crate. See the crate README for migration instructions.
Re-exports§
pub use metrics::Counter;pub use metrics::CounterAtomic;pub use metrics::Family;pub use metrics::FamilyMetricGuard;pub use metrics::Gauge;pub use metrics::GaugeAtomic;pub use metrics::GaugeGuard;pub use metrics::Histogram;pub use metrics::HistogramBuilder;pub use metrics::HistogramSnapshot;pub use metrics::HistogramTimer;pub use metrics::MetricConstructor;pub use metrics::NativeHistogram;pub use metrics::NativeHistogramBuilder;pub use metrics::NativeTimeHistogram;pub use metrics::RangeGauge;pub use metrics::TimeHistogram;pub use metrics::WithExemplar;
Modules§
- metrics
- The metrics module that contains scalar metrics (like Counter, Gauge, …) and non-scalars, like Histogram, NativeHistogram, and also Family.
- proto
- The Prometheus protobuf data model (package
io.prometheus.client).
Structs§
- Collect
Error Hook Already Set - Error returned by
set_collect_error_hookwhen a hook is already installed. - Collection
Options - Options that control which registered metrics are collected and how the service name is represented.
- Label
Error - An error produced while serializing a metric label set.
- Metric
Family - Named
Metric - A metric paired with the name and help text it is exported under.
- Registration
Metadata - Metadata attached to a metric at registration time.
Enums§
- Service
Name Format - How a service name is represented in collected metrics.
Constants§
- NAME_
REQUIREMENT - Describes what
is_valid_nameaccepts, for use in diagnostics. - OPENMETRICS_
CONTENT_ TYPE - Content type for the UTF-8 OpenMetrics text emitted by
encode_to_text. - PROTOBUF_
CONTENT_ TYPE - Content type of length-delimited Prometheus protobuf response.
Traits§
- Encode
Metric - A metric that can encode itself into the protobuf data model.
- Encode
Metric Value - Encodes metric values before registration metadata is applied.
- Info
Metric - Describes an info metric.
- Into
Metrics - Converts a value into the metrics it contributes to the registry.
Functions§
- collect
- Collects the currently registered metrics into the canonical protobuf model.
- encode_
to_ protobuf - Encodes metric families as length-delimited Prometheus protobuf messages.
- encode_
to_ text - Encodes metric families as UTF-8 OpenMetrics text.
- is_
valid_ name - Whether a metric or label name can be represented at all.
- register
- Registers one or more metrics with the given metadata.
- report_
info - Registers an info metric, i.e. a gauge metric whose value is always
1. - set_
collect_ error_ hook - Routes non-fatal metric-collection diagnostics through a custom hook.
- to_
label_ pairs - Serializes a label set into protobuf label pairs.