getsentry / getsentry/sentry-python

Ensure tag values are strings

Đang mở
#5,180 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
Improvement Python
Ngôn ngữ chính
Python
Star
2.2k
Fork
669
Merge trung bình
1 ngày 40 phút
Pull request đã merge (30 ngày)
212

Mô tả

[Tag values must be strings](https://develop.sentry.dev/sdk/data-model/event-payloads/span/); however, the Python SDK's methods for setting tags (`set_tag` on the `Scope`, on `Span`, and perhaps elsewhere) are defined as taking type `Any` for the value, and we do not convert the value to a string before setting the tag.

While this appears to not be a problem for most users (likely our transport handles non-string-valued tags), it becomes a problem for users who wish to serialize the envelopes to send them with another service, like Sentry CLI. Since our spec requires tags to have string values, other services, in particular Sentry CLI, will refuse to accept envelopes created by the Python SDK when they contain a tag with a non-string value. See for example the issue [CLI-80](https://linear.app/getsentry/issue/CLI-80/using-send-envelope-error-with-types-invalid-type-boolean-false) (GitHub getsentry/sentry-cli#2505), which is caused by the Python SDK setting a non-string-valued tag.

My proposed solution is to modify all of our `set_tag` functions to convert all values to strings before setting them on the tag. If the conversion fails, we don't set the tag.

(Follow up from [https://github.com/getsentry/sentry-python/issues/4391](https://github.com/getsentry/sentry-python/issues/4391) which was done on the potel-base branch)

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.