feat: make max spans per trace limit configurable (team + user preference) - #2860
feat: make max spans per trace limit configurable (team + user preference)#2860MikeShi42 wants to merge 1 commit into
Conversation
…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 detectedLatest commit: fafc78f The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
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 |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Greptile SummaryThe PR replaces the fixed trace-waterfall query limit with a team setting and an optional per-user override capped by that setting.
Confidence Score: 4/5The 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
|
| 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
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(), |
There was a problem hiding this comment.
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.
| traceSpanLimit: z.number().nullish(), | |
| traceSpanLimit: z.number().int().min(1000).max(500000).nullish(), |
Knowledge Base Used:
E2E Test Results✅ All tests passed • 277 passed • 1 skipped • 993s
Tests ran across 4 shards in parallel. |
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:
traceSpanLimit) — admin-configurable ceiling under ClickHouse Client Settings (min 1,000, max 500,000). Applies to everyone in the team.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.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 inDBTraceWaterfallChartnow accepts aspanLimitparameter instead of hard-coding50000. 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
packages/common-utils/src/types.tstraceSpanLimittoTeamClickHouseSettingsSchemaandTeamClickHouseSettingsUpdateSchemapackages/api/src/models/team.tstraceSpanLimit: Numberto the Mongoose schemapackages/app/src/defaults.tsDEFAULT_TRACE_SPAN_LIMIT = 50000constantpackages/app/src/useUserPreferences.tsxtraceSpanLimittoUserPreferencestypepackages/app/src/components/DBTraceWaterfallChart.tsxspanLimitparameter ingetConfig()anduseEventsAroundFocus(); compute effective limit from team + user settings in the containerpackages/app/src/components/TeamSettings/TeamQueryConfigSection.tsxpackages/app/src/UserPreferencesModal.tsxpackages/app/src/components/__tests__/DBTraceWaterfallChart.test.tsxapi.useMe()anduseUserPreferencesScreenshots 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
To show artifacts inline, enable in settings.
Linear Issue: HDX-5082