Skip to content

refactor(query-routing): centralize ASAP-first routing in EngineRouter; add range support (supersedes #309) - #347

Merged
zzylol merged 1 commit into
mainfrom
refactor/centralize-asap-first-routing
May 26, 2026
Merged

zzylol merged 1 commit into
mainfrom
refactor/centralize-asap-first-routing

Conversation

@zzylol

@zzylol zzylol commented May 26, 2026

Copy link
Copy Markdown
Contributor

What

Centralizes query routing in EngineRouter and makes http.rs a thin transport layer. Both instant and range queries now try the ASAP sketch tier first and fall back to the archive (thanos_query) on CapabilityMiss; accuracy == Exact goes straight to the archive.

Supersedes #309 — same Thanos /api/v1/query_range forwarding, but the engine selection lives in the router instead of being inlined in http.rs.

Why

Routing was split across two places: instant went through EngineRouter + compatible_storage_backends, while #309 added range routing inline in http.rs (try ASAP → on miss, hardcoded engine_by_id(thanos) lookup), bypassing the router entirely (which had no execute_range). That left http.rs making 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_range default (→ CapabilityMiss); EngineRouter::execute_range mirroring execute()'s failover over the shared compatible_storage_backends sequence.
  • asap_query_engine/engine.rs: ASAPQueryEngine::execute_range delegates to the inherent execute_range_promql_modern (so the router reaches the real warm-tier range path).
  • thanos_query_engine/forward.rs: ThanosQueryEngine::execute_range forwards 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_backendsASAP-first (Approximate → [SketchStore, GorillaObjectStore]), Exact → [GorillaObjectStore], PrometheusRemote unchanged; tests updated.
  • http.rs: process_range_query_request thinned to a single query_router.execute_range(...); inline Thanos lookup removed.

Notes

  • The Exact → archive gate is wired but dormant: the live query path still hardcodes accuracy = Approximate (matches the existing instant path). Deriving Exact from 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_matching test suites all green (incl. the warm-tier range e2e). Verified in an isolated build env (asap_sketchlib main + ASAPCollector main); CI will compile against its own pinned versions.

…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant