Skip to content

docs(logs): clarify attribute value types for Python logs#17921

Open
sergical wants to merge 2 commits into
masterfrom
sdybskiy/logs-attribute-value-types
Open

docs(logs): clarify attribute value types for Python logs#17921
sergical wants to merge 2 commits into
masterfrom
sdybskiy/logs-attribute-value-types

Conversation

@sergical
Copy link
Copy Markdown
Member

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 dicts 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

Log attribute values must be primitives (string/number/boolean) to be
stored. Same-typed scalar lists are sent as arrays that aren't currently
retained (they appear empty in the Logs UI), while mixed lists and dicts
are stored as their string representation. Document this and recommend
serializing complex values (e.g. json.dumps) before logging.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 28, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
sentry-docs Ready Ready Preview, Comment May 28, 2026 11:21pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
develop-docs Ignored Ignored Preview May 28, 2026 11:21pm

Request Review

The "Include Business Context" example showed feature_flags as a raw
list, which the Python SDK drops on ingestion (arrays aren't stored as
attributes). Show the join-to-string pattern instead so the example
actually works.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant