feat(admin): Implement lazy loading for profile events in tracing tool #7708
+282
−38
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
This PR separates profile events fetching from the main trace query API to dramatically improve response times and user experience. The trace query endpoint now returns immediately (<2s) while profile events are loaded on-demand when users expand the accordion.
Problem
The
/clickhouse_trace_queryendpoint was synchronously fetching profile events using exponential backoff (up to 23 seconds). If profile events weren't ready in ClickHouse, the entire response was blocked, causing poor UX with long wait times.Solution
/fetch_profile_eventsendpoint for lazy loadingChanges
Backend (
snuba/admin/views.py)Modified
/clickhouse_trace_queryendpointtry_gather_profile_eventsparameter handlingsettings = {"log_profile_events": 1}gather_profile_events()callCreated
/fetch_profile_eventsendpointquery_summariesandstorageparametersTracingSummaryfrom request datagather_profile_events()functionFrontend
API Client (
api_client.tsx)ProfileEventsResponseinterfacefetchProfileEvents()methodType Definitions (
types.tsx)storage?: stringfield toTracingResultQuery Display (
query_display.tsx)checkedGatherProfileEventsstateIndex Component (
index.tsx)fetchProfileEventsWithRetry()with exponential backoffPerformance Impact
Testing
Manual Testing Checklist
Backward Compatibility
✅ No breaking changes - this is purely additive with one removal (profile events toggle)
🤖 Generated with Claude Code