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=onMETRICS_FILTER=authority=off
Re-exports§
pub use core::Histogram;pub use core::HistogramTimer;pub use core::HistogramVec;
Modules§
- core
- Mirrors
prometheus::coreand providesGenericGauge/GenericCounterwrappers 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. - Histogram
Opts - 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
Metrictypes. - Protobuf
Encoder - An implementation of an
Encoderthat converts aMetricFamilyproto message into the binary wire format of protobuf. - Registry
- Wraps
prometheus::Registrywith an embeddedFilterso thatregister_*_with_registry!macros can decide at construction time whether a metric should be active. - Text
Encoder - An implementation of an
Encoderthat converts aMetricFamilyproto 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
Filterparsed once fromMETRICS_FILTER. - default_
registry - Returns a reference to the global default
Registry, wrapping the underlyingprometheus::default_registry(). Metrics registered here appear in the standard prometheus default gather output. - exponential_
buckets - Create
countbuckets, where the lowest bucket has an upper bound ofstartand each following bucket’s upper bound isfactortimes 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 ofHistogramOpts. - gather
- Return all
MetricFamilyofDEFAULT_REGISTRY. - linear_
buckets - Create
countbuckets, eachwidthwide, where the lowest bucket has an upper bound ofstart. 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 ofHistogramOpts.
Type Aliases§
- Counter
- Counter
Vec - Gauge
- Gauge
Vec - IntCounter
- IntCounter
Vec - IntGauge
- IntGauge
Vec - Result
- A specialized Result type for prometheus.