feat(query): InstantVectorElement carries per-element label_keys_override - #260
Merged
Merged
Conversation
…ride
Mirrors `RangeVectorElement` — adds an optional `label_keys_override:
Option<Vec<String>>` field so per-element keys (synthesized by
ASAP-tier `topk(...)` as `"item": <key>`) surface through the
Prometheus adapter on instant-vector responses, not just range-vector.
Three-line change spanning three files:
- `InstantVectorElement` gains the field + `with_label_keys_override`
helper (query_result.rs).
- `asap_tier_result_to_query_result`'s instant-vector branch stops
discarding the BTreeMap keys (engine.rs:3443) — the same fix
PR #256 applied to the range-vector branch.
- `convert_query_result_to_prometheus` picks per-element override
over the query-scoped `KeyByLabelNames`, mirroring
`convert_range_result_to_prometheus` (http.rs).
Tests 8+9 in `e2e_controller_plans_and_backend_serves.rs` tighten
their `topk(3, top_endpoint_qps)` assertions to verify
`metric.item == "gamma"` is present in at least one returned series
— the strict invariant that previously couldn't be checked because
the adapter dropped the synthesized key.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
zzylol
added a commit
that referenced
this pull request
May 16, 2026
Closes the range-query gap I documented in PR #260's session follow-up. Per-user direction (2026-05-16): count_over_time is warm-tier-answerable by sampling; topk_over_time isn't standard PromQL anyway and falls through to the cold tier (Thanos parse- error is acceptable). Sibling of PR #253's instant-query trait-dispatch fallback. New `ASAPQueryEngine::execute_range_promql_modern(query, start_ms, end_ms, step_ms)` mirrors the analyzer + reducer dispatch from the `QueryEngine::execute(&str)` trait surface but returns Matrix per the `/api/v1/query_range` wire-format spec. Wire-up: `process_range_query_request` in `http.rs` tries `handle_range_query_promql` first (legacy path, unchanged), and on `None` calls the new modern method. If the modern path also errors, it falls through to `format_unsupported_query_response` (which the EngineRouter can route to a cold-tier fallback). Prometheus semantics note: the spec says evaluate at each `t = start, start+step, …, end`. The warm tier returns samples at native window-close granularity instead — finer than the user's step when window_size < step (more data, not less). Step-precise evaluation is a future refinement; clients that need exact step timestamps can downsample, or route step- precise queries to the cold tier. Test 10 (`controller_plan_to_range_query_count_over_time_cms`) ingests heap-less CMS DPs via the same setup as Test 7, then queries `count_over_time(endpoint_request_freq[10s])` via `/api/v1/query_range`. Asserts `status=success`, `resultType=matrix`, non-empty series. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes the InstantVectorElement label gap from PR #258. Adds an
Option<Vec<String>>field (mirroring the existing field onRangeVectorElement) so per-element synthesized keys — notably ASAP-tier `topk(...)`'s `"item": ` — surface through the Prometheus adapter on instant-vector responses.Changes
InstantVectorElement+with_label_keys_overridehelper (query_result.rs) — matches the existingRangeVectorElementshape exactly.asap_tier_result_to_query_result's instant-vector branch stops discarding the BTreeMap keys at engine.rs:3443. Same fix PR fix(query): dispatch Vector vs Matrix in asap_tier_result_to_query_result #256 applied to the range-vector branch.convert_query_result_to_prometheuspickselement.label_keys_overrideover the query-scopedKeyByLabelNames, mirroringconvert_range_result_to_prometheus.metric.item == "gamma"fortopk(3, top_endpoint_qps). The fact-check that previously couldn't run without this fix.Test plan
cargo test --test e2e_controller_plans_and_backend_serves— all 9 pass with strictitem: \"gamma\"assertioncargo test --workspace --lib— 1549 pass, 0 fail🤖 Generated with Claude Code