Skip to main content

build_families

Function build_families 

Source
fn build_families(
    published: &BTreeMap<(String, Vec<(String, String)>), (f64, MetricKind, String)>,
) -> Vec<MetricFamily>
Expand description

Groups published by metric name into one MetricFamily per name, since Prometheus requires a single type and help string per family. Within a group, the entry with the lexicographically smallest label vector wins the family’s type and help string; BTreeMap’s (name, labels) key ordering already sorts each group that way, so the first entry seen for a given name is that winner.

MetricFamily.type_ and Metric.{gauge,counter} are protobuf wrapper types (EnumOrUnknown/MessageField).