You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(log): show custom attributes in log view (#914)
`sentry log view` showed a fixed set of fields. Custom attributes users
attach to their logs — visible in the Sentry UI — were never fetched or
displayed.
`sentry log list` already supported custom attributes via `--fields`
before this work. No changes there.
**How it works**
The Sentry UI calls a trace-items detail endpoint when expanding a log
row:
```
GET /projects/{org}/{project}/trace-items/{itemId}/?item_type=logs&trace_id={traceId}
```
It returns every attribute on the log without needing to enumerate field
names. `log view` now does the same: after `getLogs` fetches standard
fields (including `trace`), `getLogItemDetail` is called in parallel for
each log. `formatLogDetails` renders all non-standard attributes in a
**Custom Attributes** section automatically. `--fields` filters that
section when you only want specific attributes.
The endpoint is `EXPERIMENTAL` in Sentry and not yet in `@sentry/api`
(generated from `getsentry/sentry-api-schema`), so it uses
`apiRequestToRegion` directly — same pattern as `listTraceLogs`.
Attribute types mirror `TraceItemResponseAttribute`:
https://github.com/getsentry/sentry/blob/8a4f150b21b/static/app/views/explore/hooks/useTraceItemDetails.tsx#L85-L89
If the endpoint is unavailable (no trace ID on the log, or request
fails), the formatter degrades gracefully and shows only standard
fields.
**Type consolidation**
PR #623 defined `TraceItemAttribute` and `TraceItemDetail` as plain TS
types in `traces.ts`. This PR moves them to `src/types/sentry.ts` with
Zod schemas (`.passthrough()` so `meta`/`links` from the spans endpoint
are preserved), exports them via the types barrel, and re-exports from
`traces.ts` for existing callers. `getSpanDetails` also gets schema
validation for parity with `getLogItemDetail`.
**Usage**
```bash
# Shows ALL custom attributes automatically — no config needed
sentry log view myorg/myproject <id>
# Limits the Custom Attributes section to specific fields
sentry log view myorg/myproject <id> --fields order.id,user.tier
# JSON output: unchanged
sentry log view myorg/myproject <id> --json
```
---------
Co-authored-by: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
0 commit comments