Skip to content

Commit f3287ce

Browse files
sergicalclaudeKyleTryonsfanahata
authored
docs(logs): clarify attribute value types for Python logs (#17921)
## Summary Clarifies which value types are supported for Python log attributes, after a user reported that array-valued attributes (e.g. `list[int]` like `workflow_ids`/`detector_ids`) silently show up empty in the Logs UI. ## Findings (validated against a real project) Sentry's log storage (EAP) only retains **scalar** attribute types — string, number, boolean. The Python SDK (`sentry_sdk.utils.format_attribute`) sends a homogeneous scalar `list`/`tuple` as a real **array**, which the backend does not store, so it appears empty. Mixed lists and `dict`s are `repr`'d to strings and *do* survive. (For contrast, `@sentry/core` stringifies all non-primitives via `serializeAttributes(attrs, true)`, so JS users see arrays as JSON strings — the two SDKs diverge here.) ## Change Adds an `<Alert>` to the Python logs usage include documenting that attribute values should be primitives, explaining the array behavior, and recommending serializing complex values (e.g. `json.dumps(...)`) before logging. A separate `sentry-python` issue tracks the SDK-level inconsistency. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> Co-authored-by: Kyle a.k.a. TechSquidTV <git@techsquidtv.com> Co-authored-by: Shannon Anahata <shannon.anahata@gmail.com>
1 parent 29b3cd7 commit f3287ce

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

platform-includes/logs/best-practices/python.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ sentry_sdk.logger.info(
6969

7070
# Business context
7171
"order_value": 149.99,
72-
"feature_flags": ["new-checkout", "discount-v2"],
72+
# Join lists into a string — array values aren't stored as attributes
73+
"feature_flags": ",".join(["new-checkout", "discount-v2"]),
7374
}
7475
)
7576
```

platform-includes/logs/usage/python.mdx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,9 @@ sentry_sdk.logger.error(
3030
}
3131
)
3232
```
33+
34+
<Alert title="Attribute value types">
35+
36+
Attribute values should be primitives — strings, numbers, or booleans. Sentry's log storage only retains these scalar types, so other values are handled inconsistently. A `list` or `tuple` of same-typed scalars (for example `[1, 2, 3]`) is sent as an array, which is **not currently stored** and shows up empty in the Logs UI. Mixed lists and `dict`s are stored as their string representation. To keep a complex value searchable, serialize it to a string before logging, for example `json.dumps(workflow_ids)`.
37+
38+
</Alert>

0 commit comments

Comments
 (0)