Logs: array attribute values are silently dropped (and diverge from sentry-javascript)
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 64/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Công nghệ
- python
- Lĩnh vực
- observability
Hướng nghiên cứu
Bắt đầu trong sentry_sdk/utils.py tại format_attribute, khoảng dòng 2125, và theo dõi cách các thuộc tính của logger được serialize trước khi ingestion. So sánh hành vi của Python với hành vi fallback được mô tả của @sentry/core serializeAttributes. Được xem là hoàn thành khi các giá trị không nguyên thủy không còn biến mất một cách im lặng và hành vi serialize hoặc chẩn đoán đã chọn được bao phủ bởi các kiểm tra hiện có liên quan.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- Python
- Star
- 2.2k
- Fork
- 672
- Merge trung bình
- 22 giờ 47 phút
- Pull request đã merge (30 ngày)
- 224
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của getsentry/sentry-python
-
Python
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
getsentry/sentry-python#7569 · 1 bình luận ·
-
Python
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
getsentry/sentry-python#7568 · 2 bình luận ·
-
Python
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
getsentry/sentry-python#7567 · 1 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
getsentry/sentry-python#7543 · 2 bình luận · 1 người được giao ·
-
Python
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
getsentry/sentry-python#6992 · 1 bình luận ·
Tất cả issue của getsentry/sentry-python
Issue tương tự
-
essnmx good first issue
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 95/100
-
[Feature] 奇物选择添加优先级 Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
syfoud/Simulated_Scepter#174 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Giskard-AI/giskard-oss#2840 · 1 bình luận ·
-
A claim comment carrying the issue number is silently declined while the workflow reports success Đang mởarea: repo bug perceived difficulty: 2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
yeti-platform/yeti#1380 ·