Logs: array attribute values are silently dropped (and diverge from sentry-javascript)
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 64/100
- Issue-Typ
- Bug
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Ruhig
- Tech-Stack
- python
- Bereich
- observability
Rechercherichtung
Beginne in sentry_sdk/utils.py bei format_attribute um Zeile 2125 und verfolge, wie Logger-Attribute vor der Ingestion serialisiert werden. Vergleiche das Verhalten von Python mit dem beschriebenen Fallback-Verhalten von @sentry/core serializeAttributes. Erledigt bedeutet, dass nicht-primitive Werte nicht länger stillschweigend verschwinden und dass das gewählte Serialisierungs- oder Diagnoseverhalten durch die relevanten bestehenden Checks abgedeckt ist.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Environment
sentry-sdk 2.61.0, Python 3.14, logs enabled via enable_logs=True.
What happened
Passing a list-valued attribute to sentry_sdk.logger.* results in the attribute silently disappearing from the Logs UI — no value, no warning, no debug log.
sentry_sdk.logger.info(
"workflow_engine processed event",
attributes={
"workflow_ids": [101, 202, 303], # list[int] -> dropped (blank in UI)
"rule_names": ["high_cpu", "oom"], # list[str] -> dropped (blank in UI)
"organization_id": 42, # int -> stored OK
"mixed_list": [1, "two", 3.0], # mixed -> stored as the string "[1, 'two', 3.0]"
"nested_dict": {"a": [1, 2]}, # dict -> stored as the string "{'a': [1, 2]}"
},
)
Querying the log back (EAP logs dataset), the homogeneous scalar lists come back null, while the scalars and the stringified mixed/dict values are present.
Root cause
format_attribute (sentry_sdk/utils.py:2125) preserves a homogeneous scalar list/tuple as a real array, but falls back to safe_repr (a string) for mixed lists and objects:
elif isinstance(val, list):
ty = type(val[0])
if ty in (str, int, float, bool) and all(type(v) is ty for v in val):
return copy.deepcopy(val) # sent as a real array
...
return safe_repr(val) # everything else -> string
Sentry's log storage (EAP) only retains scalar attribute types (string / number / boolean), so the real arrays are dropped on ingestion. The net effect is counterintuitive: homogeneous lists vanish, but mixed lists/objects survive (as strings).
Divergence from sentry-javascript
@sentry/core (v10.50) does the opposite for logs — serializeAttributes(logAttributes, true) runs with fallback=true, so every non-primitive (arrays and objects) is JSON.stringify'd into a string attribute and shows up. Its attributes.js even has an explicit comment that it intentionally does not send real arrays yet to avoid a future breaking change. So the same logging API gives different results across SDKs.
Suggested fix
Make Python consistent with JS for now: stringify non-primitive attribute values (instead of sending homogeneous arrays that get dropped), or at minimum emit a debug log / drop-record when an attribute value can't be represented, so the loss isn't silent.
A docs note has been added in getsentry/sentry-docs#17921.
🤖 Generated with Claude Code
- Vorherrschende Sprache
- Python
- Sterne
- 2.2k
- Forks
- 680
- Ø Merge
- 1 T. 1 Std.
- Gemergte PRs (30 T.)
- 267
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus getsentry/sentry-python
-
Bug Python Waiting for: Product Owner
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 90/100
getsentry/sentry-python#7827 · 3 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
Bug Python
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
getsentry/sentry-python#7774 · 3 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
Python Task
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
getsentry/sentry-python#7663 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Python Task
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
getsentry/sentry-python#7652 · 1 Kommentar · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
-
Remove send_default_pii from httpxEvtl. vergeben @sentrivana hat das vor 8 Tagen übernommen. OffenPython
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
getsentry/sentry-python#7653 · 1 Kommentar · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in getsentry/sentry-python
Ähnliche Issues
-
#bug
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 92/100
apache/superset#44923 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 2 Tagen
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
lawndoc/stack-back#123 ·
-
Add: EntuneOffen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
AbdelStark/awesome-typesafe-jev#187 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug good first issue
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
repowise-dev/repowise#2966 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
Maintainer antworten meist innerhalb von 2 Tagen