feat(log): show custom attributes in log view#914
Merged
Conversation
getLogs and getLogsBatch now accept extraFields, which are merged with the default DETAILED_LOG_FIELDS before the API request — same pattern as listLogs. formatLogDetails renders a Custom Attributes section for any fields that were explicitly requested. The KNOWN_DETAIL_FIELDS blocklist approach was avoided; instead extraFields flows through LogViewData so the formatter only shows what was asked for. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Contributor
|
Contributor
Codecov Results 📊✅ 6678 passed | Total: 6678 | Pass Rate: 100% | Execution Time: 0ms 📊 Comparison with Base Branch
All tests are passing successfully. ✅ Patch coverage is 87.06%. Project has 13508 uncovered lines. Files with missing lines (3)
Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
+ Coverage 76.62% 76.69% +0.07%
==========================================
Files 303 303 —
Lines 57821 57961 +140
Branches 0 0 —
==========================================
+ Hits 44308 44453 +145
- Misses 13513 13508 -5
- Partials 0 0 —Generated by Codecov Action |
Replace the --fields-only approach with the trace-items detail endpoint
(/projects/{org}/{project}/trace-items/{itemId}/?item_type=logs) which
returns every attribute on the log without requiring field enumeration —
the same call the Sentry UI makes when expanding a log row.
After getLogs fetches standard fields (including trace), getLogItemDetail
is called in parallel for each log that has a trace ID. formatLogDetails
renders all non-standard attributes in a Custom Attributes section.
--fields acts as a filter on that section rather than an adder.
The endpoint is EXPERIMENTAL and not yet in @sentry/api (getsentry/
sentry-api-schema), so it uses apiRequestToRegion directly, matching
the listTraceLogs pattern. Types mirror TraceItemResponseAttribute:
https://github.com/getsentry/sentry/blob/8a4f150b21b/static/app/views/explore/hooks/useTraceItemDetails.tsx#L85-L89
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
TraceItemAttribute and TraceItemDetail were defined twice: as plain TS types in traces.ts (PR #623) and as Zod schemas in sentry.ts (this branch). Remove the plain types from traces.ts and import from the types barrel instead, re-exporting for existing callers. Also: - Add .passthrough() to TraceItemDetailSchema so meta/links from the spans endpoint are preserved without failing validation - Add schema validation to getSpanDetails, matching getLogItemDetail - Rename SHOWN_IN_STANDARD_SECTIONS → REDUNDANT_LOG_DETAIL_ATTRS to mirror REDUNDANT_DETAIL_ATTRS naming in traces.ts Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
- Wrap getLogsBatch config+extraFields into options object (useMaxParams) - Use explicit return statement in catch to satisfy both noEmptyBlock and noUselessUndefined rules - Switch TraceItem re-export in traces.ts to export-from syntax (noExportedImports), remove unused local import of TraceItemAttribute Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
BYK
reviewed
May 5, 2026
BYK
reviewed
May 5, 2026
- Add "array" variant to TraceItemAttributeSchema (Sentry backend gates this via organizations:trace-item-details-array-fields; without it the strict discriminated union throws and fetchMultiSpanDetails silently drops the span's attributes) - Cap parallel log detail fetches with pLimit(15), matching SPAN_DETAIL_CONCURRENCY used by fetchMultiSpanDetails in traces.ts - Document why getLogItemDetail uses apiRequestToRegion directly (endpoint is EXPERIMENTAL and not yet in @sentry/api / sentry-api-schema) Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
- Use limit.map() instead of Promise.all + manual wrapping, matching the fetchMultiSpanDetails pattern in traces.ts - Extract shared getTraceItemDetail helper in traces.ts; getSpanDetails and getLogItemDetail both delegate to it — only item_type differs (options object keeps param count at 4) Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…etSpanDetails Covers the three uncovered areas: - formatLogDetails: custom attributes rendering, REDUNDANT_LOG_DETAIL_ATTRS filtering, --fields filter, fallback path (extraFields without allAttributes), and empty allAttributes - view.func: getLogItemDetail called for traced logs, skipped for traceless logs, graceful degradation on failure, custom attributes appear in output - traces: getSpanDetails delegates to trace-items endpoint with item_type=spans Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit d0dd84e. Configure here.
…stringify - Skip getLogItemDetail calls when --json is set — jsonTransform only uses data.logs, not data.details, so the extra round-trips are wasted. Mirrors the shouldFetchDetails ternary pattern in trace/view.ts. - Use JSON.stringify for "array" type attributes in the Custom Attributes section instead of String(), which produces "[object Object]" for arrays containing objects. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

sentry log viewshowed a fixed set of fields. Custom attributes users attach to their logs — visible in the Sentry UI — were never fetched or displayed.sentry log listalready supported custom attributes via--fieldsbefore this work. No changes there.How it works
The Sentry UI calls a trace-items detail endpoint when expanding a log row:
It returns every attribute on the log without needing to enumerate field names.
log viewnow does the same: aftergetLogsfetches standard fields (includingtrace),getLogItemDetailis called in parallel for each log.formatLogDetailsrenders all non-standard attributes in a Custom Attributes section automatically.--fieldsfilters that section when you only want specific attributes.The endpoint is
EXPERIMENTALin Sentry and not yet in@sentry/api(generated fromgetsentry/sentry-api-schema), so it usesapiRequestToRegiondirectly — same pattern aslistTraceLogs. Attribute types mirrorTraceItemResponseAttribute: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
TraceItemAttributeandTraceItemDetailas plain TS types intraces.ts. This PR moves them tosrc/types/sentry.tswith Zod schemas (.passthrough()someta/linksfrom the spans endpoint are preserved), exports them via the types barrel, and re-exports fromtraces.tsfor existing callers.getSpanDetailsalso gets schema validation for parity withgetLogItemDetail.Usage