Skip to content

feat: make max spans per trace limit configurable (team + user preference) - #2860

Draft
MikeShi42 wants to merge 1 commit into
mainfrom
cursor/configurable-max-spans-per-trace-4e7f
Draft

feat: make max spans per trace limit configurable (team + user preference)#2860
MikeShi42 wants to merge 1 commit into
mainfrom
cursor/configurable-max-spans-per-trace-4e7f

Conversation

@MikeShi42

@MikeShi42 MikeShi42 commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Summary

Replace the hard-coded 50,000 max-spans-per-trace constant with a configurable value — a team-level setting plus an optional per-user preference clamped to the team ceiling.

Why: Class Pty asked to raise the limit on max spans per trace. The previous hard-coded value couldn't serve both large-trace customers and the default performance-safe experience without a code change and release.

How it works:

  • Team setting (traceSpanLimit) — admin-configurable ceiling under ClickHouse Client Settings (min 1,000, max 500,000). Applies to everyone in the team.
  • Personal preference (traceSpanLimit) — per-user override in the Preferences modal under a new "Performance" section. Clamped to the team ceiling so users can lower (but not exceed) it.
  • Precedence: effective = min(userPreference ?? teamSetting, teamSetting), with 50,000 as the default when neither is set.

Where the limit binds: Query-side only. The getConfig() function in DBTraceWaterfallChart now accepts a spanLimit parameter instead of hard-coding 50000. There is no render-side cap — the waterfall renders all fetched spans. The limit applies to both halves of the focus-date split query (before/after), so the effective ceiling is 2× the configured value.

Changes by file

File Change
packages/common-utils/src/types.ts Add traceSpanLimit to TeamClickHouseSettingsSchema and TeamClickHouseSettingsUpdateSchema
packages/api/src/models/team.ts Add traceSpanLimit: Number to the Mongoose schema
packages/app/src/defaults.ts Add DEFAULT_TRACE_SPAN_LIMIT = 50000 constant
packages/app/src/useUserPreferences.tsx Add optional traceSpanLimit to UserPreferences type
packages/app/src/components/DBTraceWaterfallChart.tsx Accept spanLimit parameter in getConfig() and useEventsAroundFocus(); compute effective limit from team + user settings in the container
packages/app/src/components/TeamSettings/TeamQueryConfigSection.tsx Add trace span limit setting form
packages/app/src/UserPreferencesModal.tsx Add personal trace span limit control under new "Performance" section
packages/app/src/components/__tests__/DBTraceWaterfallChart.test.tsx Add mocks for api.useMe() and useUserPreferences

Screenshots or video

User Preferences — personal trace span limit:

User Preferences modal showing trace span limit under Performance section

Team Settings — team-wide trace span limit:

Team Settings showing trace span limit under ClickHouse Client Settings

Video walkthrough:

trace_span_limit_feature_walkthrough.mp4

How to test on Vercel preview

N/A — requires server-side team settings that don't persist in Vercel preview mode. Test locally with yarn dev.

References

  • Linear Issue: HDX-5082

To show artifacts inline, enable in settings.

Linear Issue: HDX-5082

Open in Web Open in Cursor 

…ence)

Add traceSpanLimit to TeamClickHouseSettings (team-level ceiling) and
UserPreferences (per-user override clamped to team ceiling).

The limit binds query-side: getConfig() in DBTraceWaterfallChart now
accepts a spanLimit parameter instead of hard-coding 50000. The
effective limit is computed as min(userPreference, teamSetting) with
the current 50000 as the default when neither is set.

Team admins can configure the setting under ClickHouse Client Settings
(min 1000, max 500000). Individual users can set a personal preference
in the Preferences modal under a new Performance section.

Closes HDX-5082

Co-authored-by: Mike Shi <mike@hyperdx.io>
@changeset-bot

changeset-bot Bot commented Aug 11, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: fafc78f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@hyperdx/app Minor
@hyperdx/api Minor
@hyperdx/common-utils Minor
@hyperdx/otel-collector Minor

Not sure what this means? Click here to learn what changesets are.

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

@vercel

vercel Bot commented Aug 11, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
hyperdx-oss Ready Ready Preview Aug 11, 2026 7:35am
hyperdx-storybook Ready Ready Preview Aug 11, 2026 7:35am

Request Review

@greptile-apps

greptile-apps Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR replaces the fixed trace-waterfall query limit with a team setting and an optional per-user override capped by that setting.

  • Adds persistence and shared API types for the team-level trace span limit.
  • Adds team-settings and personal-preferences controls.
  • Propagates the effective limit into trace and correlated-log waterfall queries.
  • The server-side schema currently does not enforce the range advertised by those controls.

Confidence Score: 4/5

The PR should not merge until the API enforces the documented trace-span-limit range, because direct settings requests can currently persist values that break waterfall queries or bypass the resource ceiling.

The frontend bounds normal form input, but the authoritative PATCH schema accepts and persists arbitrary numbers that the waterfall later uses directly as ClickHouse query limits.

Files Needing Attention: packages/common-utils/src/types.ts

Important Files Changed

Filename Overview
packages/common-utils/src/types.ts Adds the team setting to shared schemas, but the write schema omits the integer and 1,000–500,000 constraints enforced only by the UI.
packages/api/src/models/team.ts Persists traceSpanLimit as a numeric team ClickHouse setting.
packages/app/src/components/DBTraceWaterfallChart.tsx Computes the effective team/user limit and propagates it to trace and correlated-log query configurations.
packages/app/src/components/TeamSettings/TeamQueryConfigSection.tsx Adds a bounded team-level trace span limit control with the 50,000 default.
packages/app/src/UserPreferencesModal.tsx Adds a personal trace-limit preference control capped by the currently loaded team setting.
packages/app/src/useUserPreferences.tsx Extends the persisted user-preference type with an optional trace span limit.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Team settings UI] --> B[PATCH clickhouse-settings]
  B --> C[(Team.traceSpanLimit)]
  D[Personal preference] --> E[User preference storage]
  C --> F[useMe team limit]
  E --> G[User limit]
  F --> H["min(user limit, team limit)"]
  G --> H
  H --> I[Trace before/after queries]
  H --> J[Correlated-log before/after queries]
  I --> K[Waterfall rows]
  J --> K
Loading

Fix All in Claude Code Fix All in Conductor Fix All in Cursor Fix All in Codex

Reviews (1): Last reviewed commit: "feat: make max spans per trace limit con..." | Re-trigger Greptile

metadataMaxRowsToRead: z.number().nullish(),
parallelizeWhenPossible: z.boolean().nullish(),
filterKeysFetchLimit: z.number().nullish(),
traceSpanLimit: z.number().nullish(),

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.

P1 Unbounded trace limit validation

When an authenticated team member submits an out-of-range traceSpanLimit directly to PATCH /clickhouse-settings, the unconstrained schema persists it and the waterfall uses it as a ClickHouse query limit, causing empty or failed queries or bypassing the intended 500,000-span resource ceiling.

Suggested change
traceSpanLimit: z.number().nullish(),
traceSpanLimit: z.number().int().min(1000).max(500000).nullish(),

Knowledge Base Used:

Fix in Claude Code Fix in Conductor Fix in Cursor Fix in Codex

@github-actions

Copy link
Copy Markdown
Contributor

E2E Test Results

All tests passed • 277 passed • 1 skipped • 993s

Status Count
✅ Passed 277
❌ Failed 0
⚠️ Flaky 0
⏭️ Skipped 1

Tests ran across 4 shards in parallel.

View full report →

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