feat(trace): add trace list and view commands#218
Merged
Conversation
Add sentry trace list and sentry trace view commands for exploring distributed traces from Sentry projects. trace list: shows recent transactions with trace ID, name, duration, and relative time. Supports --sort (date/duration), --query, --limit, and --json flags. Auto-detects project from DSN or accepts explicit org/project target. trace view: displays trace summary (root transaction, duration, span count, projects involved) and a span tree. Supports --spans depth limit, --web to open in browser, and --json output. Also includes: - TransactionListItem/TransactionsResponse Zod schemas and types - listTransactions() API client function - Trace-specific formatters (duration, header, row, summary) - Root span breadth cap (50) to prevent terminal flooding - Handle API returning end_timestamp instead of timestamp on spans - Limit validation (1-1000) matching log list pattern
22 unit tests covering formatTraceDuration, formatTracesHeader, formatTraceRow, computeTraceSummary, and formatTraceSummary including edge cases like NaN/zero timestamps. 26 property-based tests using fast-check verifying invariants: determinism, trace ID preservation, non-negative durations, project deduplication, and correct duration format units.
Contributor
Semver Impact of This PR🟡 Minor (new features) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨Cli
Other
Bug Fixes 🐛Upgrade
Documentation 📚
Internal Changes 🔧
🤖 This preview updates automatically when you update the PR. |
Contributor
Codecov Results 📊✅ Patch coverage is 91.55%. Project has 3986 uncovered lines. Files with missing lines (66)
Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
+ Coverage 67.47% 68.47% +1%
==========================================
Files 99 103 +4
Lines 12133 12640 +507
Branches 0 0 —
==========================================
+ Hits 8186 8654 +468
- Misses 3947 3986 +39
- Partials 0 0 —Generated by Codecov Action |
Export internal helpers (validateLimit, parseSort, resolveTraceTarget, writeHumanOutput) and add direct unit tests for the command func() bodies using spyOn to mock api-client and resolve-target. This covers the code paths that e2e tests exercise but can't contribute to coverage since they run as subprocesses.
b3bb520 to
d258f5c
Compare
…llback - Fix formatTraceDuration producing 'Xm 60s' when seconds round up to 60 by computing total seconds first then splitting into mins/secs - Remove unused buildTracesUrl function (dead code) - Use || instead of ?? for end_timestamp fallback so 0 falls through to the valid timestamp field
d258f5c to
81b4725
Compare
…uman.ts Same fix as trace.ts — end_timestamp: 0 is invalid and should fall through to timestamp field.
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.
This was referenced Feb 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
sentry trace listandsentry trace viewcommands for exploring distributed traces. Follows the same patterns as the existinglogandissuecommands — auto-detect from DSN, explicit org/project target, project search across orgs.Features
trace list— Recent transactions with trace ID, name, duration, and relative time--sort date|duration,--query,--limit 1-1000,--jsontracesshortcut registered at top level (likeissues,logs)trace view <trace-id>— Trace summary + span tree--spansdepth limit (default 3),--webto open in Sentry UI,--jsonUsage Examples
Implementation Notes
TransactionListItemSchema/TransactionsResponseSchema(Zod)listTransactions()usingdataset=transactionson the events endpointend_timestampinstead oftimestampon spanscomputeTraceSummary()handle spans with zero/missing timestamps gracefully (renders "—" instead of NaN)log listpattern