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§
- Column
Indices 🔒 - Column indices resolved once from the sink’s source relation.
- Sink
Collector 🔒 - A
prometheus::core::Collectorthat exposes a metric sink’sSinkState. - Sink
State 🔒 - Working and published metric state for one metric sink.
Enums§
Functions§
- build_
families 🔒 - Groups
publishedby metric name into oneMetricFamilyper 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/helpdisagree with their family’s winning type/help. Seebuild_familiesfor how the winner is chosen. - count_
skipped 🔒 - Counts live working rows dropped for an unsupported
metric_typeor 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
workinginto one published entry per(metric_name, labels)series and counts colliding and null-suppressed series.
Type Aliases§
- Published
Key 🔒 - Key into
SinkState::published: a metric name paired with its sorted label vector. - Published
Value 🔒 - 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.