Repository navigation
Conversation
Own the render metrics accumulator in the provider, submit metrics only once per dashboard, and record query states after commit instead of during render. Signed-off-by: Guillaume LADORME <gladorme@gmail.com>
…ilure Return early from markQuery once metrics are submitted, log a warning when the submission request fails, and cover the DataQueriesProvider recording (batch registration, no recording from uncommitted renders). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Guillaume LADORME <Gladorme@users.noreply.github.com>
Gladorme
marked this pull request as ready for review
October 2, 2026 15:02
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.
Description
Split out of #319 to ease review (independent from the other split PRs, based on
main).Fix and simplify usage metrics collection.
UsageMetricsProviderpreviously rebuilt its accumulator object on every render, so pending query state, error count and the "already submitted" flag could be lost. The accumulator now lives in a ref owned by the provider, and metrics are submitted only once per dashboard (the provider is keyed by project/dashboard, so switching dashboard starts a fresh measurement).DataQueriesProviderrecords query states in an effect (after commit) instead of during render, and registers the whole batch as pending before completing cached queries.useUsageMetrics()returns a stablemarkQuery.markQueryreturns early once metrics are submitted, so later query updates (refreshes, time range changes) cost nothing.UsageMetricsProvidertests, plusDataQueriesProvider.usage-metrics.test.tsxcovering batch registration with a cached query and no recording from renders that are never committed.UsageMetricsContext/useUsageMetricsContext()now containsproject,dashboard,apiPrefixandmarkQuery; the internal accumulator fields (startRenderTime,renderDurationMs,renderErrorCount,pendingQueries,fetchFn) were removed. I'm not aware of consumers reading those fields directly, but tell me if you'd prefer to flag this as[BREAKINGCHANGE].Validation on this branch:
npm run lint,npm run format:check,npm run type-checkandnpm run testall pass.Screenshots
No visual change.
Checklist
[<catalog_entry>] <commit message>naming convention using one of thefollowing
catalog_entryvalues:FEATURE,ENHANCEMENT,BUGFIX,BREAKINGCHANGE,DOC,IGNORE.UI Changes
See e2e docs for more details. Common issues include: