feat(span): make span list dual-mode and add --period flag#461
Conversation
Make `sentry span list` work in two modes (like `log list`): - **Project mode** (no trace ID): lists spans across the entire project - `sentry span list` — auto-detect org/project - `sentry span list <org>/<project>` — explicit - `sentry span list <project>` — search across orgs - **Trace mode** (trace ID provided): existing behavior preserved - `sentry span list <trace-id>` - `sentry span list <org>/<project>/<trace-id>` Disambiguation uses `isTraceId()` to detect 32-char hex trace IDs, following the same pattern as `parseLogListArgs()` in `log/list.ts`. Also adds standardized `--period/-t` flag: - `span list`: new `--period` flag (default '7d') - `trace list`: new `--period` flag (default '7d') - Shared `LIST_PERIOD_FLAG` and `PERIOD_ALIASES` constants in `list-command.ts` for consistency across commands This addresses user feedback that `span list` was only useful for drilling into traces you already have, while project-wide span search required the verbose `sentry api` command.
Semver Impact of This PR🟡 Minor (new features) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨
Bug Fixes 🐛
Internal Changes 🔧
🤖 This preview updates automatically when you update the PR. |
Codecov Results 📊✅ 116 passed | Total: 116 | Pass Rate: 100% | Execution Time: 0ms 📊 Comparison with Base Branch
✨ No test changes detected All tests are passing successfully. ✅ Patch coverage is 100.00%. Project has 1147 uncovered lines. Files with missing lines (1)
Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
+ Coverage 95.21% 95.23% +0.02%
==========================================
Files 176 176 —
Lines 23934 24064 +130
Branches 0 0 —
==========================================
+ Hits 22787 22917 +130
- Misses 1147 1147 —
- Partials 0 0 —Generated by Codecov Action |
Enhance buildListCommand to automatically inject --fresh, --cursor flags, their aliases (-f, -c), and auto-call applyFreshFlag() — reducing boilerplate in every list command. Commands that conflict can opt out via ListCommandOptions: - noCursorFlag: skip --cursor and -c (log list uses streaming) - noFreshAlias: skip -f alias (log list uses -f for --follow) Flags already defined by the command are preserved (e.g., issue list keeps its custom --cursor brief). Cleaned up all 6 buildListCommand consumers: - span list, trace list, project list: removed cursor, fresh, aliases - issue list: removed fresh flag and alias (keeps custom cursor) - log list: removed fresh flag, added opt-outs - buildOrgListCommand: removed redundant fresh/cursor declarations
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Both parseSpanListArgs (span/list.ts) and parseLogListArgs (log/list.ts) had near-identical control flow for detecting whether positional args contain a trace ID. Extracted the shared logic into parseDualModeArgs() in trace-target.ts, parameterized by the usage hint string. Both commands now delegate to this shared utility via thin wrappers. Addresses BugBot review feedback about duplicated argument disambiguation.
|
Addressed in 92e1103 — extracted the shared dual-mode disambiguation logic into |

Summary
Make
sentry span listwork in two modes (likelog list):Previously,
span listrequired a trace ID — users who wanted to search spans across a project had to use the verbosesentry apicommand. Nowsentry span list(orsentry spans) defaults to project-wide search.Disambiguation uses
isTraceId()on the positional args, following the same pattern asparseLogListArgs()inlog/list.ts.--period/-tflagAdds a standardized
--period/-tflag to bothspan listandtrace list(both previously hardcoded to 7 days):LIST_PERIOD_FLAGandPERIOD_ALIASESconstants inlist-command.ts"7d", accepts Sentry duration strings ("1h","24h","30d")Examples