feat(trace): consistent project filtering across trace commands (#737)#743
feat(trace): consistent project filtering across trace commands (#737)#743
Conversation
When a user provides `org/project/trace-id`, all trace commands now
filter results to that project via API-level filtering:
- `trace view`: resolves project slug to numeric ID, passes to the
trace detail API instead of hardcoded `project: -1`
- `trace logs` / `log list` (trace mode): prepends `project:{slug}`
to the query param sent to the trace-logs endpoint
- `span list`: already worked, no changes to filtering logic
Additional UX improvements:
- Orphan parent indicator in span tree when API filters by project
and root spans have parents in other projects
- Conditional "Project" column in span table when spans come from
multiple projects
- Contextual hints with real org/project/trace values for copy-paste
- Multi-project `--query "project:[a,b]"` syntax documented in flag
briefs and doc fragments
Closes #737
Semver Impact of This PR🟡 Minor (new features) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨
Bug Fixes 🐛Init
Resolve
Upgrade
Other
Internal Changes 🔧
🤖 This preview updates automatically when you update the PR. |
|
Codecov Results 📊✅ 134 passed | Total: 134 | Pass Rate: 100% | Execution Time: 0ms 📊 Comparison with Base Branch
✨ No test changes detected All tests are passing successfully. ✅ Patch coverage is 97.00%. Project has 1634 uncovered lines. Files with missing lines (2)
Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
+ Coverage 95.28% 95.28% —%
==========================================
Files 234 234 —
Lines 34545 34605 +60
Branches 0 0 —
==========================================
+ Hits 32913 32971 +58
- Misses 1632 1634 +2
- Partials 0 0 —Generated by Codecov Action |
The hasOrphanedParent check ran unconditionally, showing a misleading "parent span in another project" message on normal unfiltered traces where root spans legitimately have parent_span_id at service boundaries. Now gated behind a projectFiltered option passed by trace view only when the user explicitly provided org/project/trace-id.
Extract buildProjectQuery to arg-parsing.ts as a shared helper. Remove inline duplicate from trace/logs.ts and local copy from log/list.ts. Both now import from the shared location. Also remove orphaned JSDoc comment left over from conflict resolution.
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.
Reviewed by Cursor Bugbot for commit d330500. Configure here.
The type was inserted between the JSDoc block and the function, orphaning the documentation from its declaration.

Summary
org/project/trace-id, all trace commands now filter results to that project via API-level filteringtrace view,trace logs,log list(trace mode) were silently discarding the project segment — now consistent withspan listChanges
API:
getDetailedTraceaccepts optionalprojectId— passes to the Sentry trace detail endpoint instead of hardcodedproject: -1trace view: Resolves project slug → numeric ID viagetProject(), passes to API. Only filters when user explicitly typedorg/project/trace-id(parsed.type === "explicit").trace logs/log list(trace mode): Prependsproject:{slug}to the query param sent to the trace-logs endpoint. Same pattern asspan listuses with the Events API.Span tree: Shows
⤴ parent span in another projectwhen root spans have orphaned parents (filtered out by project).Span table: Auto-prepends a "Project" column when spans come from multiple
project_slugvalues.Hints: All hints interpolate actual org, project, trace ID:
Filtered to project 'cli-server'. Full trace: sentry trace view my-org/abc123...This trace spans 4 projects (...). Filter: sentry trace view my-org/cli/abc123...Docs:
--querybriefs updated to mentionproject:[a,b]syntax. Cross-project examples added to span.md and trace.md fragments.Closes #737