Issue Description
(Similar to #1911)
Hello,
I got the error Transaction sending failed: "\xD9" from ASCII-8BIT to UTF-8 that's raised from this method:
|
def initialize(headers, payload) |
|
@headers = headers |
|
@payload = payload |
|
end |
Here is the log:

We're using MessagePack to serialize data before storing them into Redis. The encoding of the string returned by MessagePack is ASCII_8BIT. This string is captured in a Sentry span description, and the serialization into JSON fails due to the invalid encoding:

We try to fix this issue using the before_send hook, but unfortunately we've not been able to find spans in the event object.
We finally fixed this issue by monkey patching the set_description method of the Sentry::Span class:

Is this a known issue that should be fixed in Sentry SDK directly? If not, is there a way to deal with non UTF-8 string using the before_send hook?
Reproduction Steps
In a Rails project with Sentry and MessagePack installed:
Sentry.capture_message(MessagePack.pack('test message'))
Expected Behavior
Event is sent to Sentry.
Actual Behavior
Event isn't sent to Sentry.
Ruby Version
2.7.4
SDK Version
5.7.0
Integration and Its Version
rails (6.0.5.1), sentry-rails (5.7.0), sidekiq (5.2.2), sentry-sidekiq (5.7.0)
Sentry Config
# frozen_string_literal: true
Sentry.init do |config|
config.dsn = ENV['SENTRY_DSN']
config.breadcrumbs_logger = [:active_support_logger, :http_logger]
# Tracing Options
config.traces_sample_rate = 1.0
end
Issue Description
(Similar to #1911)
Hello,
I got the error
Transaction sending failed: "\xD9" from ASCII-8BIT to UTF-8that's raised from this method:sentry-ruby/sentry-ruby/lib/sentry/envelope.rb
Lines 12 to 15 in 193446b
Here is the log:
We're using MessagePack to serialize data before storing them into Redis. The encoding of the string returned by MessagePack is
ASCII_8BIT. This string is captured in a Sentry span description, and the serialization into JSON fails due to the invalid encoding:We try to fix this issue using the
before_sendhook, but unfortunately we've not been able to find spans in the event object.We finally fixed this issue by monkey patching the
set_descriptionmethod of theSentry::Spanclass:Is this a known issue that should be fixed in Sentry SDK directly? If not, is there a way to deal with non UTF-8 string using the
before_sendhook?Reproduction Steps
In a Rails project with Sentry and MessagePack installed:
Sentry.capture_message(MessagePack.pack('test message'))Expected Behavior
Event is sent to Sentry.
Actual Behavior
Event isn't sent to Sentry.
Ruby Version
2.7.4
SDK Version
5.7.0
Integration and Its Version
rails (6.0.5.1), sentry-rails (5.7.0), sidekiq (5.2.2), sentry-sidekiq (5.7.0)
Sentry Config