Skip to main content

Crate foundations_metrics

Crate foundations_metrics 

Source
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§

CollectErrorHookAlreadySet
Error returned by set_collect_error_hook when a hook is already installed.
CollectionOptions
Options that control which registered metrics are collected and how the service name is represented.
LabelError
An error produced while serializing a metric label set.
MetricFamily
NamedMetric
A metric paired with the name and help text it is exported under.
RegistrationMetadata
Metadata attached to a metric at registration time.

Enums§

ServiceNameFormat
How a service name is represented in collected metrics.

Constants§

NAME_REQUIREMENT
Describes what is_valid_name accepts, 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§

EncodeMetric
A metric that can encode itself into the protobuf data model.
EncodeMetricValue
Encodes metric values before registration metadata is applied.
InfoMetric
Describes an info metric.
IntoMetrics
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.