Skip to content

perf(issue-list): use collapse parameter to skip unused Snuba queries#545

Merged
BYK merged 2 commits intomainfrom
perf/issue-list-collapse
Mar 24, 2026
Merged

perf(issue-list): use collapse parameter to skip unused Snuba queries#545
BYK merged 2 commits intomainfrom
perf/issue-list-collapse

Conversation

@BYK
Copy link
Member

@BYK BYK commented Mar 24, 2026

The Sentry web UI optimizes issue list loading by sending collapse parameters to /organizations/{org}/issues/, telling the server to skip computing data the client won't use. This avoids expensive Snuba/ClickHouse queries and saves 200-500ms per API request.

What gets collapsed

Field When Rationale
filtered Always Never consumed by CLI issue list
lifetime Always CLI uses period-scoped count/userCount, not lifetime
unhandled Always Only used in issue view, not issue list
stats JSON mode, narrow terminal, non-TTY Only needed for TREND sparkline column (≥100 cols)

When stats are collapsed, groupStatsPeriod is also omitted since the server won't compute stats anyway.

Changes

  • Add IssueCollapseField type and buildIssueListCollapse() pure function to the API layer
  • Add collapse parameter to listIssuesPaginated/listIssuesAllPages
  • Add willShowTrend() helper to formatters (keeps process.stdout out of command files)
  • Thread collapse through all three API call paths: fetchIssuesForTarget, fetchWithBudget, fetchOrgAllIssues
  • Property tests for buildIssueListCollapse invariants
  • Integration tests verifying collapse reaches the API

Context

Investigation of the Sentry backend showed the /issues/ endpoint uses a dual-database (PostgreSQL + Snuba) pipeline. Each collapse value skips a round of Snuba queries in the StreamGroupSerializerSnuba serializer. The Discover endpoint (/events/?dataset=errors) cannot replace issue listing since issues are aggregations above events.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 24, 2026

Semver Impact of This PR

🟢 Patch (bug fixes)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

  • Native debug ID injection and sourcemap upload by BYK in #543

Internal Changes 🔧

Coverage

  • Use informational-patch input instead of sed hack by BYK in #544
  • Make checks informational on release branches by BYK in #541

Other

  • (ci) Upgrade GitHub Actions to Node 24 runtime by BYK in #542
  • (issue-list) Use collapse parameter to skip unused Snuba queries by BYK in #545
  • Regenerate skill files by github-actions[bot] in ec1ffe28

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 24, 2026

Codecov Results 📊

126 passed | Total: 126 | Pass Rate: 100% | Execution Time: 0ms

📊 Comparison with Base Branch

Metric Change
Total Tests
Passed Tests
Failed Tests
Skipped Tests

✨ No test changes detected

All tests are passing successfully.

✅ Patch coverage is 100.00%. Project has 1028 uncovered lines.
✅ Project coverage is 96.04%. Comparing base (base) to head (head).

Files with missing lines (2)
File Patch % Lines
human.ts 96.43% ⚠️ 46 Missing
issues.ts 99.31% ⚠️ 1 Missing
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    96.04%    96.04%        —%
==========================================
  Files          186       186         —
  Lines        25897     25929       +32
  Branches         0         0         —
==========================================
+ Hits         24869     24901       +32
- Misses        1028      1028         —
- Partials         0         0         —

Generated by Codecov Action

@BYK BYK marked this pull request as ready for review March 24, 2026 00:54
The Sentry web UI optimizes issue list loading by sending collapse
parameters to /organizations/{org}/issues/, telling the server to
skip computing data the client won't use. This avoids expensive
Snuba/ClickHouse queries and saves 200-500ms per API request.

The CLI's issue list command never consumes filtered, lifetime, or
unhandled fields — these are always collapsed. The stats field
(sparkline data for the TREND column) is conditionally collapsed
when sparklines won't be rendered: JSON mode, narrow terminals
(<100 cols), and non-TTY output.

When stats are collapsed, groupStatsPeriod is also omitted since
the server won't compute stats anyway.

Changes:
- Add IssueCollapseField type and buildIssueListCollapse() to API layer
- Add collapse parameter to listIssuesPaginated/listIssuesAllPages
- Add willShowTrend() helper to formatters (avoids process.stdout in commands)
- Thread collapse through fetchIssuesForTarget, fetchWithBudget, fetchOrgAllIssues
- Property tests for buildIssueListCollapse invariants
- Integration tests verifying collapse reaches the API
@BYK BYK force-pushed the perf/issue-list-collapse branch from 93e846f to 4da341b Compare March 24, 2026 00:59
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

- Remove ?? 'auto' fallback in fetchIssuesForTarget so intentional
  undefined from buildListApiOptions flows through (Seer)
- Refactor writeIssueTable to call willShowTrend() instead of
  duplicating the terminal width check inline (Bugbot)
@BYK BYK merged commit 6b343d1 into main Mar 24, 2026
22 checks passed
@BYK BYK deleted the perf/issue-list-collapse branch March 24, 2026 08:14
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.

1 participant