Skip to main content

Crate prometheus_filtered

Crate prometheus_filtered 

Source
Expand description

Drop-in replacement for the prometheus crate with optional per-metric filtering.

Replace use prometheus::* with use prometheus_filtered::* and set METRICS_FILTER (or call Registry::with_filter) to control which metrics are registered.

Filter syntax: comma-separated pattern=on|off directives, last-match wins. A bare off or on sets the global default. A pattern matches if it is a prefix of the metric name OR is a component/prefix of the calling module path (e.g. traffic_controller matches iota_core::traffic_controller::metrics).

Examples:

  • METRICS_FILTER=off,authority=on
  • METRICS_FILTER=authority=off

Re-exports§

pub use core::Histogram;
pub use core::HistogramTimer;
pub use core::HistogramVec;

Modules§

core
Mirrors prometheus::core and provides GenericGauge/GenericCounter wrappers compatible with prometheus’s own generic types.
proto
Protocol buffers format of metrics. Generated file from proto_model.proto

Macros§

histogram_opts
Create a HistogramOpts.
opts
Create an Opts.
register_counter
register_counter!(name, help) - global prometheus registry, filtered.
register_counter_vec
register_counter_vec!(name, help, labels) - global registry, filtered.
register_counter_vec_with_registry
register_counter_vec_with_registry!(name, help, labels, registry)
register_gauge_vec_with_registry
register_gauge_vec_with_registry!(name, help, labels, registry)
register_gauge_with_registry
register_gauge_with_registry!(name, help, registry)
register_histogram_vec
register_histogram_vec!(opts, labels) or (name, help, labels) or (name, help, labels, buckets) — global prometheus registry, filtered.
register_histogram_vec_with_registry
register_histogram_vec_with_registry!(name, help, labels, registry) register_histogram_vec_with_registry!(name, help, labels, buckets, registry)
register_histogram_with_registry
register_histogram_with_registry!(name, help, registry) register_histogram_with_registry!(name, help, buckets, registry)
register_int_counter_vec_with_registry
register_int_counter_vec_with_registry!(name, help, labels, registry)
register_int_counter_with_registry
register_int_counter_with_registry!(name, help, registry)
register_int_gauge_vec_with_registry
register_int_gauge_vec_with_registry!(name, help, labels, registry)
register_int_gauge_with_registry
register_int_gauge_with_registry!(name, help, registry)

Structs§

Filter
Parses and evaluates METRICS_FILTER-style directives.
HistogramOpts
A struct that bundles the options for creating a [Histogram] metric. It is mandatory to set Name and Help to a non-empty string. All other fields are optional and can safely be left at their zero value.
Opts
A struct that bundles the options for creating most Metric types.
ProtobufEncoder
An implementation of an Encoder that converts a MetricFamily proto message into the binary wire format of protobuf.
Registry
Wraps prometheus::Registry with an embedded Filter so that register_*_with_registry! macros can decide at construction time whether a metric should be active.
TextEncoder
An implementation of an Encoder that converts a MetricFamily proto message into text format.

Enums§

Error
The error types for prometheus.

Constants§

DEFAULT_BUCKETS
The default [Histogram] buckets. The default buckets are tailored to broadly measure the response time (in seconds) of a network service. Most likely, however, you will be required to define buckets customized to your use case.
PROTOBUF_FORMAT
The protocol buffer format of metric family.

Traits§

Encoder
An interface for encoding metric families into an underlying wire protocol.

Functions§

default_filter
Returns the process-wide Filter parsed once from METRICS_FILTER.
default_registry
Returns a reference to the global default Registry, wrapping the underlying prometheus::default_registry(). Metrics registered here appear in the standard prometheus default gather output.
exponential_buckets
Create count buckets, where the lowest bucket has an upper bound of start and each following bucket’s upper bound is factor times the previous bucket’s upper bound. The final +Inf bucket is not counted and not included in the returned slice. The returned slice is meant to be used for the Buckets field of HistogramOpts.
gather
Return all MetricFamily of DEFAULT_REGISTRY.
linear_buckets
Create count buckets, each width wide, where the lowest bucket has an upper bound of start. The final +Inf bucket is not counted and not included in the returned slice. The returned slice is meant to be used for the Buckets field of HistogramOpts.

Type Aliases§

Counter
CounterVec
Gauge
GaugeVec
IntCounter
IntCounterVec
IntGauge
IntGaugeVec
Result
A specialized Result type for prometheus.