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.
- Pending
Registration ๐ - Active-worker collector registration that tolerates a transient descriptor-id collision with an incarnation of this sink that has not been torn down yet.
- Sink
Collector ๐ - A
prometheus::core::Collectorthat exposes a metric sinkโsSinkState. - Sink
State ๐ - Working and published metric state for one metric sink.
Enumsยง
- Metric
Kind ๐ - Retry ๐
- Whether a registration attempt left a collision the caller must arm a retry for.
Constantsยง
- REGISTRATION_
ESCALATE_ ๐AFTER - How long a collision may persist before it soft-panics.
- REGISTRATION_
RETRY_ ๐INTERVAL - How long to wait before retrying a collector registration that collided.
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_type, an invalid Prometheus metric or label name, or a null or empty label value. - extract_
row ๐ - Extracts
(metric_name, metric_kind, name_valid, sorted labels, value, help)from one shaped source row. - is_
publishable_ ๐label_ value - Whether a label value can be published as-is. A null (
None) has no value to encode, and an empty string reads as absent to Prometheus, so{a => ''}would fold into{}. Both make the row that carries them unpublishable. - 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.