Skip to content

perf(webapp): shrink run trace loader payload and add trace span cap controls#3906

Merged
ericallam merged 5 commits into
mainfrom
perf/trace-page-quick-wins
Jun 11, 2026
Merged

perf(webapp): shrink run trace loader payload and add trace span cap controls#3906
ericallam merged 5 commits into
mainfrom
perf/trace-page-quick-wins

Conversation

@ericallam

Copy link
Copy Markdown
Member

Summary

The run trace page loader serialized every span's raw OTel events (with full properties) into the response, even though the tree UI only renders the derived timelineEvents and the span detail panel refetches what it needs. On event-heavy traces that inflated both the loader payload and the server-side heap copies built per request. This PR keeps raw span events server-side and pairs that with a few related trace-view improvements:

  • A new optional TRACE_VIEW_EMERGENCY_SPAN_CAP env var (unset by default) clamps the trace summary and detailed trace summary span limits on both event store paths, including the public run trace endpoint, so operators can bound trace query sizes in one place without retuning the per-store limits.
  • The TreeView virtualizer resolved every rendered row with a linear scan over the whole tree (and getNodeProps did the same via findIndex); rows now resolve through memoized id lookup maps, which matters once traces reach tens of thousands of spans.
  • The run stream SSE lookup now applies the same organization membership scoping as the rest of the run page presenters, for consistency.

Behavior is unchanged by default: the trace tree renders from the same timelineEvents it always has, and the new cap only takes effect when set.

…ayload

The trace tree only renders the derived timelineEvents, so the raw span
events (with full properties) were serialized into the loader response
as dead weight on event-heavy traces. Raw events now stay server-side,
and timeline events no longer carry the raw event properties (the field
was never in the TimelineSpanEvent type and nothing rendered it).
A new optional TRACE_VIEW_EMERGENCY_SPAN_CAP env var clamps the trace
summary and detailed trace summary span limits on both event store
paths (ClickHouse and Postgres), covering the dashboard trace view and
the public run trace endpoint. Unset by default, so nothing changes
unless an operator sets it.
The SSE stream route resolved runs by friendly id alone. The lookup now
applies the same organization membership scoping as the rest of the run
page presenters, on both the database lookup and the buffered-run
fallback, with unauthorized indistinguishable from missing.
The virtualizer render path ran tree.find per virtual row and
getNodeProps ran tree.findIndex per rendered node, which is quadratic
work on large traces. Both now resolve through memoized id-to-index
maps with identical behavior.
@changeset-bot

changeset-bot Bot commented Jun 11, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: f5f7f53

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 00a242b1-941d-4990-85b6-219d837c438d

📥 Commits

Reviewing files that changed from the base of the PR and between f2377b7 and f5f7f53.

📒 Files selected for processing (1)
  • .server-changes/trace-page-payload-diet.md
✅ Files skipped from review due to trivial changes (1)
  • .server-changes/trace-page-payload-diet.md
📜 Recent review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (15)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (8, 10)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (7, 10)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (9, 10)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (1, 10)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (10, 10)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (3, 10)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (6, 10)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (2, 10)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (5, 10)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (4, 10)
  • GitHub Check: e2e-webapp / 🧪 E2E Tests: Webapp
  • GitHub Check: typecheck / typecheck
  • GitHub Check: audit
  • GitHub Check: audit
  • GitHub Check: Analyze (javascript-typescript)

Walkthrough

This PR introduces three coordinated improvements to the trace page system. The primary change slims client payloads by extracting raw span events on the server and removing them from serialized data, while timeline events continue to be derived server-side. An optional emergency span cap environment variable provides a safety mechanism to clamp trace query limits across both event store implementations. Authorization is strengthened by requiring user identity validation in RunStreamPresenter and scoping trace access to the user's organization. Finally, TreeView rendering is optimized by replacing linear array scans with memoized Map-based O(1) lookups for both node resolution and index computation.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is missing the required checklist section, testing steps section, and changelog section as specified in the repository template. Add the complete PR template including the checklist, Testing section with specific test steps, and Changelog section describing the changes.
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main changes: payload shrinking by removing raw span events and adding trace span cap controls.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch perf/trace-page-quick-wins

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@ericallam ericallam marked this pull request as ready for review June 11, 2026 15:51
coderabbitai[bot]

This comment was marked as resolved.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

@ericallam ericallam merged commit 187c047 into main Jun 11, 2026
33 checks passed
@ericallam ericallam deleted the perf/trace-page-quick-wins branch June 11, 2026 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants