Skip to content

feat(logs): Add JSON pretty-printing for log attributes#111077

Merged
JoshuaKGoldberg merged 4 commits intomasterfrom
json-log-attribute-pretty-printing
Mar 27, 2026
Merged

feat(logs): Add JSON pretty-printing for log attributes#111077
JoshuaKGoldberg merged 4 commits intomasterfrom
json-log-attribute-pretty-printing

Conversation

@JoshuaKGoldberg
Copy link
Copy Markdown
Member

@JoshuaKGoldberg JoshuaKGoldberg commented Mar 19, 2026

Add pretty-printing for JSON attribute values in the logs attributes tree.

String attribute values that contain valid JSON ({ or [ that pass JSON.parse) are now rendered using StructuredEventData instead of plain text, providing a collapsible, syntax-highlighted tree view.

Simple JSON where all values are primitives (e.g. {"boop": "bop"}) renders compactly inline via CSS overrides, while nested structures get the full expandable tree with toggle buttons. The styled wrapper also resets <pre> default margins to keep the tree row grid layout properly aligned.

Screenshot of logs with object and array attribute values syntax-highlighted

Fixes LOGS-400

Made with Cursor

@linear-code
Copy link
Copy Markdown

linear-code bot commented Mar 19, 2026

@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Mar 19, 2026
@JoshuaKGoldberg JoshuaKGoldberg force-pushed the json-log-attribute-pretty-printing branch from 2dd46b3 to 943f493 Compare March 25, 2026 14:24
@JoshuaKGoldberg JoshuaKGoldberg force-pushed the json-log-attribute-pretty-printing branch from 943f493 to 1163792 Compare March 25, 2026 14:30
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Mar 25, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🚨 Warning: This pull request contains Frontend and Backend changes!

It's discouraged to make changes to Sentry's Frontend and Backend in a single pull request. The Frontend and Backend are not atomically deployed. If the changes are interdependent of each other, they must be separated into two pull requests and be made forward or backwards compatible, such that the Backend or Frontend can be safely deployed independently.

Have questions? Please ask in the #discuss-dev-infra channel.

@JoshuaKGoldberg JoshuaKGoldberg force-pushed the json-log-attribute-pretty-printing branch from 8c8b184 to 8db213f Compare March 25, 2026 15:47
@JoshuaKGoldberg JoshuaKGoldberg removed the Scope: Backend Automatically applied to PRs that change backend components label Mar 25, 2026
@JoshuaKGoldberg JoshuaKGoldberg marked this pull request as ready for review March 27, 2026 14:13
@JoshuaKGoldberg JoshuaKGoldberg requested a review from a team as a code owner March 27, 2026 14:13
Comment thread static/app/views/explore/components/traceItemAttributes/attributesTreeValue.tsx Outdated
@JoshuaKGoldberg JoshuaKGoldberg requested a review from a team as a code owner March 27, 2026 16:46
* Attempts to parse a JSON string, recursively unwrapping double-stringified arrays.
*/
export function tryParseJson(value: unknown): unknown {
export function tryParseJsonRecursive(value: unknown): unknown {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

See #111077 (comment): renaming this to disambiguate. Both in general and from the tryParseJson I added to attributesTreeValue.tsx.

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 prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Compact mode hides collapsed content indicators in nested JSON
    • Changed CSS selector from 'button' to 'button[aria-label]' to only hide toggle buttons while preserving NumItemsButton that shows collapsed content indicators.

Create PR

Or push these changes by commenting:

@cursor push 7bca11c525
Preview (7bca11c525)
diff --git a/static/app/views/explore/components/traceItemAttributes/attributesTreeValue.tsx b/static/app/views/explore/components/traceItemAttributes/attributesTreeValue.tsx
--- a/static/app/views/explore/components/traceItemAttributes/attributesTreeValue.tsx
+++ b/static/app/views/explore/components/traceItemAttributes/attributesTreeValue.tsx
@@ -129,7 +129,7 @@
       padding-left: 0;
     }
 
-    button {
+    button[aria-label] {
       display: none;
     }

This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.

Comment thread static/app/views/explore/components/traceItemAttributes/attributesTreeValue.tsx Outdated
@JoshuaKGoldberg JoshuaKGoldberg merged commit 6b00c83 into master Mar 27, 2026
69 of 70 checks passed
@JoshuaKGoldberg JoshuaKGoldberg deleted the json-log-attribute-pretty-printing branch March 27, 2026 17:37
@github-actions github-actions bot locked and limited conversation to collaborators Apr 12, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants