Skip to main content

foundations_metrics/
lib.rs

1//! Metric types, collection, and Prometheus encoders for `foundations`.
2//!
3//! This crate provides counters, gauges, histograms, metric families, and
4//! encoders for OpenMetrics text and Prometheus protobuf formats. It uses
5//! `foundations-metrics-registry` for the process-global registry and protobuf
6//! data model.
7//!
8//! `foundations` currently re-exports these APIs from
9//! `foundations::telemetry::metrics`. Libraries can depend on this crate
10//! directly, to maximize compatibility with foundations' versions. However,
11//! binaries which use foundations should still use the top-level `foundations`
12//! crate. See the crate README for migration instructions.
13#![warn(missing_docs)]
14
15mod collect;
16mod diagnostics;
17mod encoding;
18mod info;
19mod labels;
20pub mod metrics;
21mod registered;
22mod validation;
23mod value;
24
25pub use collect::{CollectionOptions, ServiceNameFormat, collect};
26pub use diagnostics::{CollectErrorHookAlreadySet, set_collect_error_hook};
27pub use encoding::{
28    OPENMETRICS_CONTENT_TYPE, PROTOBUF_CONTENT_TYPE, encode_to_protobuf, encode_to_text,
29};
30pub use foundations_metrics_registry::{
31    EncodeMetric, IntoMetrics, MetricFamily, RegistrationMetadata, proto, register,
32};
33pub use info::{InfoMetric, report_info};
34pub use labels::{LabelError, to_label_pairs};
35pub use metrics::{
36    Counter, CounterAtomic, Family, FamilyMetricGuard, Gauge, GaugeAtomic, GaugeGuard, Histogram,
37    HistogramBuilder, HistogramSnapshot, HistogramTimer, MetricConstructor, NativeHistogram,
38    NativeHistogramBuilder, NativeTimeHistogram, RangeGauge, TimeHistogram, WithExemplar,
39};
40pub use registered::NamedMetric;
41pub use validation::{NAME_REQUIREMENT, is_valid_name};
42pub use value::EncodeMetricValue;