perf(api): faster iOS service detail, widgets and per-request auth - #1088
Merged
Merged
Conversation
The v2 service overview and widget summary timeseries never set rootSpansOnly, so they skipped the service_overview minutely/hourly rollups and scanned every raw span of the service or org. The phone's service detail screen waited 18-30s on that read for a busy service. Both now read entry spans (the same population as their summary numbers) and route to the rollups. The widget summary also runs its issues, catalog and series reads concurrently instead of one after another.
|
Note A newer push replaced |
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (4)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
ensureServedHere re-read Clerk every 5s for any org without a chosen region, which is every org that predates regions. In practice that was a Clerk call on ~74% of API requests (p50 163ms, p95 588ms) ahead of the handler. The 5s TTL only protects an org that can still choose EU. The choice is refused once an org is past REGION_CHOICE_WINDOW_MS, so key the short TTL on organizationRegionOpen (unchosen and inside the window) instead of "unchosen".
|
Note Maple is reviewing this pull request at |
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.
Why
The iOS service detail screen sometimes took 20s+ to load. Traces show every
GET /v2/services/:name/overviewin the last week took 18-30s (median 23.6s), and nearly all of it was one warehouse read: the all-metrics timeseries.That read never set
rootSpansOnly, andcanUseAnnualServiceOverviewrequiresrootOnly === trueto route to theservice_overview_minutely/service_overview_hourlyrollups. So it fell through to a rawtracesscan of every span of the service, with quantiles. Foringestover 24h that is 23.6s. The summary and operations reads in the same request finish in under 1s./v2/widget_summary(the Home Screen widgets, ~1k calls/week, server p50 2.2s, p95 5.3s) had the same gap in its sparkline series, plus its three reads ran serially.What changed
rootSpansOnly: true. The read routes to the minutely rollup plus the raw edge onservice_overview_spans. This also fixes a population mismatch: the chart counted every span while the summary above it counts entry spans. The web service page already reads entry spans (custom-charts.ts).throughput_per_secondcounts), with whole-second bounds like the catalog. Issues, catalog and both series now run concurrently.OrganizationRegionService):ensureServedHerere-read Clerk every 5s for any org without a chosen region, which includes every org that predates regions. That was a Clerk call on ~74% of API requests (p50 163ms, p95 588ms) before the handler ran. The 5s TTL now applies only while an org can still choose its region (organizationRegionOpen: unchosen and inside the 7-dayREGION_CHOICE_WINDOW_MS, the same ruleOrganizationServiceenforces when the choice is written). Everything else caches for the existing 60s.rootSpansOnly: trueto the query engine.Verification
FROM service_overview_spans, service_overview_minutelyinstead ofFROM traces.vitestontelemetry.http.test.tsandwidget-summary.http.test.ts: 21 passed.apps/apiandpackages/backendtypecheck clean (the test-config typecheck has pre-existing stub errors intelemetry.http.test.ts, none in the new lines).Reviewer notes
🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Summary by CodeRabbit