Conversation
Gate PRs touching app/api/metrics, lib/metrics, and lib/db/index.ts (the metricsDb pool concurrency cap) behind a metrics-db-reviewed label applied by a non-author. Guardrail for the 2026-05-29 DB CPU incident class, which only manifests at prod data volume.
…-gate ci: add metrics DB review label gate
Wrap getAnalyticsSummary / getTimeSeries / getNetworkBreakdown in a keyed TTL cache (lib/analytics/cache.ts) so the GET routes and the SSE summary push share one DB round-trip per (org, range, project, window), and widen the SSE checksum poll from 2s to 5s. This collapses the per-viewer summary recompute - including the unindexed JSONB gas scans - that was saturating prod DB CPU. Scope the runs-table gas/network aggregation to the page's execution IDs instead of the whole org+window slice, so opening the runs table no longer runs the JSONB gas extraction over every row in range. KEEP-684: analytics read cache + SSE cadence. KEEP-685: page the runs gas aggregation.
cache.ts imports server-only; the package throws when resolved outside a Server Component, so the unit suite must stub it (same pattern as workflow-logging.test.ts).
… runs pagination tiebreak Only named ranges are keyed into the per-process analytics cache. Custom ranges carry caller-supplied start/end strings that are effectively single-use, so keying on them grew the Map without bound (a cheap memory-pressure vector) for no hit-rate benefit; those now recompute directly via isCacheableRange. Add a secondary id key to both the paged-execution-ids subquery and the outer runs page query so their independent ORDER BY ... LIMIT evaluations resolve started_at ties to the same rows, preventing a boundary row from losing its gas aggregation.
perf: cache analytics read paths and page the runs gas aggregation
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.
No description provided.