SceneQueryController: Do not mark query as complete on PartialResult state#1383
Open
SceneQueryController: Do not mark query as complete on PartialResult state#1383
Conversation
…state Previously, registerQueryWithController called queryCompleted() on the first non-Loading emission, including LoadingState.Streaming and the new LoadingState.PartialResult. This caused SceneRenderProfiler to fire "All queries completed" as soon as the first intermediate chunk arrived from split queries (e.g. Loki's querySplitting), rather than waiting for the final Done. PartialResult (added in grafana/grafana#118796) is a new state used by Loki's querySplitting and shardQuerySplitting to signal that more data is still incoming and a final Done will follow. Unlike Streaming (which is used for live-forever tail queries), PartialResult always terminates. This change skips queryCompleted() when the state is PartialResult, so the profiler only records completion after the final Done arrives. Streaming is left unchanged — it still completes immediately, preserving existing behaviour for live tail queries. Co-Authored-By: Claude Sonnet 4.6 <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
registerQueryWithControllernow skipsqueryCompleted()when the emitted state isLoadingState.PartialResult, soSceneRenderProfileronly fires "All queries completed" after the finalDonearrivesStreamingbehaviour is unchanged — live tail queries still complete immediately on the first emissionPartialResultdoes not complete the query, one asserting thatStreamingstill doesContext
LoadingState.PartialResultis a new state introduced in grafana/grafana#118796. It is used by Loki'squerySplittingandshardQuerySplittingto mark intermediate chunks of a split query — unlikeStreaming(used for live tail queries that run indefinitely),PartialResultalways terminates with a finalDone.Before this fix,
registerQueryWithControllertreatedPartialResultidentically toStreaming: it firedqueryCompleted()on the first non-Loadingemission. This meantSRP: All queries completedwould fire as soon as the first split chunk arrived, giving an inaccurate measurement of the true query duration.After this fix (verified via Playwright with sceneProfiling enabled on a 7-day Loki dashboard),
SRP: All queries completedfires only after all split chunks have returned their finalDone, with timings of 4700–5400 ms reflecting the actual full-range query completion.Merge order
This PR depends on
grafana/grafana#118796being merged and@grafana/schemapublished with thePartialResultenum value before this can be released. TheLoadingState.PartialResultcheck will silently no-op at runtime until then (the enum value resolves toundefinedin older schema versions).Test plan
yarn test:scenes -- --testPathPattern="SceneQueryController"passeslocalStorage.setItem('grafana.debug.sceneProfiling', 'true')— confirmSRP: All queries completedfires only after all panels have logged their final query timing🤖 Generated with Claude Code