Skip to content

feat(span): make span list dual-mode and add --period flag#461

Merged
BYK merged 3 commits intomainfrom
feat/span-list-dual-mode
Mar 18, 2026
Merged

feat(span): make span list dual-mode and add --period flag#461
BYK merged 3 commits intomainfrom
feat/span-list-dual-mode

Conversation

@BYK
Copy link
Copy Markdown
Member

@BYK BYK commented Mar 18, 2026

Summary

Make sentry span list work in two modes (like log list):

  • Project mode (no trace ID): lists spans across the entire project
  • Trace mode (trace ID provided): existing trace-scoped behavior preserved

Previously, span list required a trace ID — users who wanted to search spans across a project had to use the verbose sentry api command. Now sentry span list (or sentry spans) defaults to project-wide search.

Disambiguation uses isTraceId() on the positional args, following the same pattern as parseLogListArgs() in log/list.ts.

--period/-t flag

Adds a standardized --period/-t flag to both span list and trace list (both previously hardcoded to 7 days):

  • Shared LIST_PERIOD_FLAG and PERIOD_ALIASES constants in list-command.ts
  • Default "7d", accepts Sentry duration strings ("1h", "24h", "30d")
  • Included in pagination context keys to prevent cursor collisions across different time windows

Examples

# Project mode (new)
sentry span list                        # auto-detect org/project
sentry span list my-org/my-project      # explicit
sentry span list -q "op:db"             # find all DB spans
sentry span list -q "duration:>100ms"   # slow spans
sentry span list --period 24h           # last 24 hours

# Trace mode (existing, preserved)
sentry span list <trace-id>
sentry span list <org>/<project>/<trace-id>

# Period flag also on trace list
sentry trace list --period 30d

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.
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 18, 2026

Semver Impact of This PR

🟡 Minor (new features)

📋 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 ✨

  • (span) Make span list dual-mode and add --period flag by BYK in #461
  • Refactor SKILL.md into modular reference files by BYK in #458

Bug Fixes 🐛

  • (test) Use os.tmpdir() for test temp directories by BYK in #457
  • Clean up upgrade output and hide empty table headers by BYK in #459
  • Improve error messages — fix ContextError/ResolutionError misuse by BYK in #456

Internal Changes 🔧

  • (list) Align all list commands to issue list standards by BYK in #453

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 18, 2026

Codecov Results 📊

116 passed | Total: 116 | 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 1147 uncovered lines.
✅ Project coverage is 95.23%. Comparing base (base) to head (head).

Files with missing lines (1)
File Patch % Lines
list-command.ts 98.61% ⚠️ 3 Missing
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
@BYK BYK marked this pull request as ready for review March 18, 2026 18:27
Copy link
Copy Markdown

@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.

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.
@BYK
Copy link
Copy Markdown
Member Author

BYK commented Mar 18, 2026

Addressed in 92e1103 — extracted the shared dual-mode disambiguation logic into parseDualModeArgs() in trace-target.ts, parameterized by the usage hint string. Both span list and log list now delegate to it via thin wrappers.

@BYK BYK merged commit 1e4782e into main Mar 18, 2026
22 checks passed
@BYK BYK deleted the feat/span-list-dual-mode branch March 18, 2026 19:25
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