refactor(query-routing): centralize ASAP-first routing in EngineRouter; add range support (supersedes #309) - #347
Merged
Conversation
…r; add range support Routing decisions now live in one place (EngineRouter + compatible_storage_backends); http.rs is a thin transport layer. Both instant and range queries try the ASAP sketch tier first and fall back to the archive (thanos_query) on CapabilityMiss, except accuracy==Exact goes straight to the archive. Supersedes PR #309's inline approach. - QueryEngine: add `execute_range` (default returns CapabilityMiss). - EngineRouter: add `execute_range` mirroring `execute()`'s failover over the shared `compatible_storage_backends` sequence. - ASAPQueryEngine: `execute_range` delegates to `execute_range_promql_modern` so the router reaches the real warm-tier range path. - ThanosQueryEngine: implement `execute_range` forwarding to `/api/v1/query_range` (4xx -> CapabilityMiss, 5xx/timeout -> Backend), ported from #309. - compatible_storage_backends: ASAP-first (Approximate -> [SketchStore, GorillaObjectStore]); Exact -> archive only; PrometheusRemote unchanged. Tests updated. - http.rs: `process_range_query_request` thinned to a single `query_router.execute_range` call; inline Thanos lookup removed. accuracy is still hardcoded `Approximate` on the live path (matches the instant path); the `Exact -> archive` gate is wired but dormant until a request can declare accuracy. cargo check + routing/thanos/http/capability_matching tests green. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
3 tasks
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.
What
Centralizes query routing in
EngineRouterand makeshttp.rsa thin transport layer. Both instant and range queries now try the ASAP sketch tier first and fall back to the archive (thanos_query) onCapabilityMiss;accuracy == Exactgoes straight to the archive.Supersedes #309 — same Thanos
/api/v1/query_rangeforwarding, but the engine selection lives in the router instead of being inlined inhttp.rs.Why
Routing was split across two places: instant went through
EngineRouter+compatible_storage_backends, while #309 added range routing inline inhttp.rs(try ASAP → on miss, hardcodedengine_by_id(thanos)lookup), bypassing the router entirely (which had noexecute_range). That lefthttp.rsmaking engine-selection decisions and the two query types routing by different criteria. This consolidates the decision into one place.Changes
query_engine_routing.rs:QueryEngine::execute_rangedefault (→CapabilityMiss);EngineRouter::execute_rangemirroringexecute()'s failover over the sharedcompatible_storage_backendssequence.asap_query_engine/engine.rs:ASAPQueryEngine::execute_rangedelegates to the inherentexecute_range_promql_modern(so the router reaches the real warm-tier range path).thanos_query_engine/forward.rs:ThanosQueryEngine::execute_rangeforwards to/api/v1/query_range(4xx →CapabilityMiss, 5xx/timeout →Backend), ported from feat (thanos-ASAPCollector): implement /api/v1/query_range forwarding in ThanosQueryEngine #309.capability_matching.rs:compatible_storage_backends→ ASAP-first (Approximate → [SketchStore, GorillaObjectStore]),Exact → [GorillaObjectStore],PrometheusRemoteunchanged; tests updated.http.rs:process_range_query_requestthinned to a singlequery_router.execute_range(...); inline Thanos lookup removed.Notes
Exact → archivegate is wired but dormant: the live query path still hardcodesaccuracy = Approximate(matches the existing instant path). DerivingExactfrom a request (query param / header / per-metric config) is a follow-up — until then everything is ASAP-first.Verification
cargo check -p data_plane+ the routing / thanos / http range /capability_matchingtest suites all green (incl. the warm-tier range e2e). Verified in an isolated build env (asap_sketchlibmain+ ASAPCollectormain); CI will compile against its own pinned versions.