Skip to content

feat(explore): Add raw names to trace item details API - #130132

Merged
mjq merged 1 commit into
masterfrom
mjq/raw-attribute-names-be
Nov 6, 2026
Merged

mjq merged 1 commit into
masterfrom
mjq/raw-attribute-names-be

Conversation

@mjq

@mjq mjq commented Nov 5, 2026

Copy link
Copy Markdown
Member

In the trace item details endpoint, expose a new rawName field behind the organizations:trace-item-details-raw-attribute-names flag.

This will enable us to conditionally show the original, unaliased name to users. This is just an internal test on the Data Browsing team for now.

See EXP-1386.

In the trace item details endpoint, expose a new `rawName` field behind
the `organizations:trace-item-details-raw-attribute-names` flag.

This will enable us to conditionally show the original, unaliased name
to users.
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Nov 5, 2026
@mjq
mjq added this pull request to stack #130134 November 5, 2026 21:10
@mjq mjq changed the title feat(api): Add raw names to trace item detail attributes feat(explore): Add raw names to trace item details API Nov 5, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit d6f40c2. Configure here.

@mjq
mjq marked this pull request as ready for review November 5, 2026 21:16
@mjq
mjq requested a review from a team as a code owner November 5, 2026 21:16
@linear-code

linear-code Bot commented Nov 5, 2026

Copy link
Copy Markdown

EXP-1386

@mjq
mjq merged commit 1b1c983 into master Nov 6, 2026
102 of 103 checks passed
@mjq
mjq deleted the mjq/raw-attribute-names-be branch November 6, 2026 15:44
BYK added a commit that referenced this pull request Nov 9, 2026
Part of the #130351 proposal to publish the endpoints the Sentry CLI
calls today with raw API requests, so they reach the public schema and
the generated `@sentry/api` SDK.

Owner: Data Browsing.

`GET /projects/{org}/{project}/trace-items/{item_id}/`
(`ProjectTraceItemDetailsEndpoint`) goes from `EXPERIMENTAL` to
**`PUBLIC_EXPERIMENTAL`**. It stays experimental because the response
shape is still changing (for example, `rawName` was added in #130132 on
2026-11-06).

### Evidence
- Age: added in #86235 (2025-03-04); `trace_id` became required in
#87905 (2025-03-25).
- Callers: the Explore trace-item details hook
(`static/app/views/explore/hooks/useTraceItemDetails.tsx`), the logs
table rows and the trace drawer's "view JSON" links, plus the Sentry
CLI.

### Changes
**Commit 1: tooling, `feat(apidocs): Add an opt-in JsonValue response
field type`**
- `sentry.apidocs.formats.JsonValue` (`Annotated[object,
ApiJsonValue()]`) renders as an explicit `anyOf` of object, array,
string, number and boolean, described as "Any JSON value".
- The response-coverage ratchet treats a `JsonValue` field as typed and
doesn't descend into it. Its `x-sentry-json-value` marker is only
emitted under `OPENAPIGENERATE` and is stripped on deref, like the cycle
marker.
- It's opt-in. **No existing operation changes**: after this commit
`openapi-derefed.json` is byte-identical to master.
- Unit tests in `tests/sentry/apidocs` and a README paragraph.

**Commit 2: the endpoint**
- `PUBLIC_EXPERIMENTAL`, `Explore` tag, `retrieveProjectTraceItem` /
"Retrieve a Trace Item".
- Documented params, checked against the serializer and the handler:
`item_id`, `trace_id` (required), `item_type` (required; enum of the
supported item types), `routing_hint`, `timestamp`,
`statsPeriod`/`start`/`end`. `referrer` and the superuser-only `debug`
stay undocumented.
- `TraceItemDetailsResponse` and the nested `TraceItemLink`,
`TraceItemLinkAttribute` and `TraceItemEvent` TypedDicts. The serializer
helpers now return them.
- `JsonValue` is used only for the free-form fields: the `meta` values
(including the superuser `meta.debug_info`) and
`event.contexts`/`extra`/`breadcrumbs`. Everything else is typed
exactly.
- `TraceItemAttribute` (`sentry/search/eap/types.py`) gets field
descriptions. Its `value` is narrowed to `ScalarValueType |
list[ScalarValueType]`: the only producer skips attributes without a
value, so `None` was never returned. The skip check changed from `and`
to `or`, which is the same at runtime (both are `None` or neither is)
but lets mypy narrow the type.
- 400s now use `as_validation_errors(serializer)`, the same shape as the
other published endpoints.
- Span and log response examples, and an apidocs test for both (a log
with event fields, a span with links).
- Agent-token permission matrix: a real log stored in EAP backs the new
row, because the matrix requires a 200.

### Verification
- `make build-api-docs` and a diff against master: only
`retrieveProjectTraceItem` and its `TraceItemDetailsResponse` component
are added. Nothing else changes.
- Response-coverage ratchet: 0 fixed, 0 new entries.
- `pnpm run validate-api-examples`: no errors.
- `pytest tests/apidocs` 156 passed; `tests/sentry/apidocs` 170 passed.
- Endpoint tests:
`tests/snuba/api/endpoints/test_project_trace_item_details.py` 23
passed, 1 xpassed;
`tests/sentry/api/endpoints/test_project_trace_item_details.py` 33
passed; `test_organization_events_occurrences.py` 20 passed, 1 xfailed;
`test_organization_events_span_indexed.py` 181 passed, 3 skipped, 5
xfailed, 2 xpassed.
- Snuba-backed tests failed under `-n3` with different failures on each
run, which is likely xdist flakiness. Every file passed when rerun on
its own without xdist.
- Agent-token matrix: 328 passed, 23 xfailed (the new row passes).
- prek and mypy (pre-push) pass on the changed files.

The "(Optional) Shows the difference between the prod and dev schema"
check is expected to fail on PRs that change the schema.

<!-- junior-request-attribution:start -->
via @BYK.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:agent%3A22c5e57fa755cece5122380dcb72ec8e -->

--

[View
Session](https://junior-prod.sentry.dev/conversations/agent%3A22c5e57fa755cece5122380dcb72ec8e)
[[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3A22c5e57fa755cece5122380dcb72ec8e/?project=4510944073809921)

<!-- junior-session-footer:end -->

---------

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: BYK <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants