Skip to main content

shape_metric_sink_source

Function shape_metric_sink_source 

Source
fn shape_metric_sink_source(
    from_id: GlobalId,
    from_desc: &RelationDesc,
) -> (MirRelationExpr, RelationDesc)
Expand description

Extends the metric sink’s imported relation with the row-wise shaping the operator otherwise has to do in Rust: coalesces labels/help to their identity element, and adds two columns the operator reads instead of parsing strings on its hot path:

  • metric_kind (Int32, nullable): 0 for gauge, 1 for counter, NULL for any other metric_type.
  • name_valid (Bool, nullable): whether metric_name matches the Prometheus metric-name grammar (see METRIC_NAME_PATTERN). The operator treats a NULL the same as false.

No row is dropped or filtered here: the operator still needs every row, including the ones this marks invalid, to count skipped/null_values. Only the pure per-row shaping moves to MIR. Dedup, collision detection, and family-conflict counting stay in the operator, because they need cross-row state (the frontier-gated fold) that a Map can’t express.

TODO: A full move would also express the dedup/collision/family-conflict logic in MIR (e.g. via Reduce + FirstValue), collapsing the operator to a plain fold over the live set. That full move is deferred: the tiebreak fidelity that logic needs is easier to keep correct hand-written and unit-tested for now.