Skip to main content

Module prometheus_protobuf

Module prometheus_protobuf 

Source
Available on crate feature prometheus_protobuf only.
Expand description

Prometheus protobuf implementation.

// Returns `Vec<MetricFamily>`, the top-level container type. Please refer to [metrics.proto](https://github.com/prometheus/prometheus/blob/main/prompb/io/prometheus/client/metrics.proto) for details.
let metric_families = encode(&registry).unwrap();

let family = metric_families.first().unwrap();
assert_eq!("my_counter_total", family.name);
assert_eq!("This is my counter.", family.help);

For wire-format exposition, serialize each returned MetricFamily with length-delimited protobuf framing. encode_to_vec provides the exact payload used with application/vnd.google.protobuf;proto=io.prometheus.client.MetricFamily;encoding=delimited.

Modules§

prometheus_data_model
Data models generated from Prometheus io.prometheus.client protobuf.

Enums§

EncodeError
Errors returned by encode_to_vec.

Functions§

encode
Encode the metrics registered with the provided Registry into Prometheus MetricFamily messages.
encode_to_vec
Encode the metrics registered with the provided Registry into a length-delimited Prometheus protobuf payload.