Skip to content

fix(cli): preserve trace attributes in field projections - #1665

Merged
betegon merged 1 commit into
mainfrom
fix/cli-trace-fields
Oct 26, 2026
Merged

betegon merged 1 commit into
mainfrom
fix/cli-trace-fields

Conversation

@betegon

@betegon betegon commented Oct 25, 2026

Copy link
Copy Markdown
Member

trace view --fields could request an attribute successfully and then discard it when filtering the JSON response. Attribute names were looked up on the trace root even though their values live on individual spans.

Before

For a trace whose root and child spans have http.method values:

sentry trace view <trace-id> --json --fields http.method
{}

The workaround was to add spans, returning the entire tree instead of just the requested attribute. Explicit paths such as spans.data.http.method also failed because the shared filter did not traverse nested arrays or resolve nested keys containing literal dots.

After

The same command returns the requested attribute throughout the tree, retaining span IDs and parent/child structure:

{
  "spans": [
    {
      "span_id": "root-span",
      "additional_attributes": { "http.method": "GET" },
      "children": [
        {
          "span_id": "child-span",
          "additional_attributes": { "http.method": "POST" },
          "children": []
        }
      ]
    }
  ]
}

Explicit JSON paths select only the named level; selecting spans still keeps the full tree. Their structural prefixes are no longer sent to Sentry as attribute names. The shared filter preserves array positions and literal dotted keys, combines overlapping selections, and leaves the input unchanged. Missing fields remain optional; null, 0, false, and empty strings are preserved when selected.

Regression tests cover request parameters and rendered command output, including attributes found only on children, mixed summary/attribute selections, nested arrays, and overlapping fields. Command examples and generated agent documentation explain the selection rules.

Automatic JSON detail fetching is unchanged. Optimizing those requests is deferred to a separate PR.

Validation passed: root pnpm run tsc and pnpm run lint, command-fragment and documentation-example checks, and the full workspace pnpm run test on Linux x64 with Node 24 and UTC (VITEST_MAX_WORKERS=4, unprivileged user). The CLI suite passed 11,380 tests with 49 skipped.

@vercel

vercel Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
sentry-local Skipped Skipped Oct 26, 2026 12:42pm UTC

Request Review

@betegon
betegon marked this pull request as ready for review October 26, 2026 12:41
@betegon
betegon force-pushed the fix/cli-trace-fields branch from 09a3a98 to bf604eb Compare October 26, 2026 12:42
@github-actions github-actions Bot added the risk: medium PR risk score: medium label Oct 26, 2026

@BYK BYK left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's ship this

@betegon
betegon merged commit ccb8755 into main Oct 26, 2026
26 checks passed
@betegon
betegon deleted the fix/cli-trace-fields branch October 26, 2026 18:38

This branch was previously deployed

1 inactive deployment
Preview — bf604eb0 Deployed Oct 26, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants