Skip to main content

Module metric_sink

Module metric_sink 

Source
Expand description

Render arm for MetricSinkConnection.

A metric sink funnels every row of its source collection to one worker, folds it into a SinkState, and exposes that state to the process’s Prometheus registry through a SinkCollector. SinkState is shared between the timely operator (the sole writer) and SinkCollector::collect (the reader, invoked from whatever thread scrapes the registry) via Arc<Mutex<_>>. Both sides only ever hold the lock across a short, synchronous section: the operator has no await points (it is a synchronous builder_rc operator), and the collector only clones out the data it needs to build MetricFamily protos before releasing the lock.

The planner (optimize::metric_sink::shape_metric_sink_source) does the row-wise shaping: it coalesces labels/help to their identity element and computes the metric_kind and name_valid columns extract_row reads below, so this module no longer parses metric_type strings or validates metric_name itself. Dedup, collision detection, and family-conflict counting stay here because they need the cross-row state of the fold.

Structs§

ColumnIndices 🔒
Column indices resolved once from the sink’s source relation.
SinkCollector 🔒
A prometheus::core::Collector that exposes a metric sink’s SinkState.
SinkState 🔒
Working and published metric state for one metric sink.

Enums§

MetricKind 🔒

Functions§

build_families 🔒
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.
count_conflicts 🔒
Counts published series whose own metric_type/help disagree with their family’s winning type/help. See build_families for how the winner is chosen.
count_skipped 🔒
Counts live working rows dropped for an unsupported metric_type or an invalid Prometheus metric or label name.
extract_row 🔒
Extracts (metric_name, metric_kind, name_valid, sorted labels, value, help) from one shaped source row.
is_valid_label_name 🔒
Matches Prometheus’s label name grammar: [a-zA-Z_][a-zA-Z0-9_]*.
rebuild_published 🔒
Collapses the live, representable rows of working into one published entry per (metric_name, labels) series and counts colliding and null-suppressed series.

Type Aliases§

PublishedKey 🔒
Key into SinkState::published: a metric name paired with its sorted label vector.
PublishedValue 🔒
Value in SinkState::published: the series’ value, kind, and help string.
RowKey 🔒
Full identity of one source row: metric name, sorted labels, value, metric kind, name validity, and help.