Skip to content

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

Merged
sergical merged 5 commits into
masterfrom
sdybskiy/logs-attribute-value-types
Jun 2, 2026
Merged

docs(logs): clarify attribute value types for Python logs#17921
sergical merged 5 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)
develop-docs Ready Ready Preview, Comment Jun 2, 2026 6:39pm
sentry-docs Ready Ready Preview, Comment Jun 2, 2026 6:39pm

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>
@KyleTryon KyleTryon self-requested a review June 1, 2026 17:33
Comment thread platform-includes/logs/usage/python.mdx Outdated
Copy link
Copy Markdown
Contributor

@sfanahata sfanahata left a comment

Choose a reason for hiding this comment

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

@sergical - not going to block you, but can we update the run-on sentence alert with my suggestions, or something similar?

@sergical sergical merged commit f3287ce into master Jun 2, 2026
21 checks passed
@sergical sergical deleted the sdybskiy/logs-attribute-value-types branch June 2, 2026 19:09
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.

3 participants