Skip to content

feat(trace): consistent project filtering across trace commands (#737)#743

Merged
BYK merged 4 commits intomainfrom
feat/737-project-filter-trace-commands
Apr 14, 2026
Merged

feat(trace): consistent project filtering across trace commands (#737)#743
BYK merged 4 commits intomainfrom
feat/737-project-filter-trace-commands

Conversation

@BYK
Copy link
Copy Markdown
Member

@BYK BYK commented Apr 13, 2026

Summary

  • When a user provides org/project/trace-id, all trace commands now filter results to that project via API-level filtering
  • trace view, trace logs, log list (trace mode) were silently discarding the project segment — now consistent with span list
  • Contextual hints with real values for easy copy-paste, orphan parent indicators, and auto Project column in span tables

Changes

API: getDetailedTrace accepts optional projectId — passes to the Sentry trace detail endpoint instead of hardcoded project: -1

trace view: Resolves project slug → numeric ID via getProject(), passes to API. Only filters when user explicitly typed org/project/trace-id (parsed.type === "explicit").

trace logs / log list (trace mode): Prepends project:{slug} to the query param sent to the trace-logs endpoint. Same pattern as span list uses with the Events API.

Span tree: Shows ⤴ parent span in another project when root spans have orphaned parents (filtered out by project).

Span table: Auto-prepends a "Project" column when spans come from multiple project_slug values.

Hints: All hints interpolate actual org, project, trace ID:

  • Filtered: Filtered to project 'cli-server'. Full trace: sentry trace view my-org/abc123...
  • Multi-project: This trace spans 4 projects (...). Filter: sentry trace view my-org/cli/abc123...

Docs: --query briefs updated to mention project:[a,b] syntax. Cross-project examples added to span.md and trace.md fragments.

Closes #737

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

github-actions bot commented Apr 13, 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 ✨

  • (cli) Add sentry cli defaults command for persistent settings by BYK in #721
  • (docs) Auto-generate driftable documentation sections by BYK in #739
  • (issue-list) Add search syntax docs, case-insensitive AND/OR, and JSON syntax reference by BYK in #738
  • (trace-view) Expose span attributes in trace and span views by BYK in #742

Bug Fixes 🐛

Init

  • Treat no-op edits as passthrough instead of throwing by betegon in #731
  • Remove JSON minification that breaks edit-based codemods by betegon in #719

Resolve

  • Address review comments and add tests for fuzzy project recovery by BYK in #732
  • Fuzzy auto-recovery for project slug resolution by BYK in #728

Upgrade

  • Detect npm install method from node_modules path by BYK in #723
  • Add shell option on Windows for .cmd package managers by BYK in #722

Other

  • (ci) Add retry logic to ORAS/bsdiff downloads and upgrade ORAS by BYK in #741
  • (dashboard) Remove overly restrictive dataset-display cross-validation by BYK in #720
  • (errors) Improve ContextError wording for auto-detect failures by BYK in #726
  • (issue) Support share issue URLs by BYK in #718
  • (issue-list) Auto-correct AND and reject OR in --query to prevent 400 by BYK in #727
  • (telemetry) Rename isClientApiError to isUserApiError and exclude 400 by BYK in #729
  • Bug fixes from Sentry error monitoring (CLI-FR, CLI-RN) + auth default by BYK in #740

Internal Changes 🔧

  • Regenerate skill files by github-actions[bot] in ca16b2ff

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 13, 2026

PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://cli.sentry.dev/_preview/pr-743/

Built to branch gh-pages at 2026-04-13 23:57 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 13, 2026

Codecov Results 📊

134 passed | Total: 134 | 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 97.00%. Project has 1634 uncovered lines.
✅ Project coverage is 95.28%. Comparing base (base) to head (head).

Files with missing lines (2)
File Patch % Lines
src/lib/arg-parsing.ts 75.00% ⚠️ 2 Missing
src/lib/formatters/human.ts 80.00% ⚠️ 1 Missing
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

@BYK BYK marked this pull request as ready for review April 13, 2026 23:31
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.
Copy link
Copy Markdown
Contributor

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

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.
@BYK BYK merged commit 1c59110 into main Apr 14, 2026
26 checks passed
@BYK BYK deleted the feat/737-project-filter-trace-commands branch April 14, 2026 00:13
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.

feat: support filtering spans by project within a trace

1 participant