getsentry / sentry-ruby

Sentry SDK for Ruby
https://sentry.io/for/ruby
MIT License
938 stars 495 forks source link

Deprecation warning with json gem 2.8.0+ #2462

Open fschwahn opened 1 week ago

fschwahn commented 1 week ago

Issue Description

The json-gem has introduced deprecation warnings in 2.8.0, see https://github.com/ruby/json/pull/643. When using Sentry this leads to the following deprecation:

/app/vendor/bundle/ruby/3.3.0/gems/json-2.8.1/lib/json/common.rb:288: warning: JSON.generate: UTF-8 string passed as BINARY, this will raise an encoding error in json 3.0 (RubyWarningHandler::Warning)

/app/vendor/bundle/ruby/3.3.0/gems/json-2.8.1/lib/json/common.rb:288:in `generate',
/app/vendor/bundle/ruby/3.3.0/gems/json-2.8.1/lib/json/common.rb:288:in `generate',
/app/vendor/bundle/ruby/3.3.0/gems/sentry-ruby-5.21.0/lib/sentry/envelope/item.rb:37:in `to_s',
/app/vendor/bundle/ruby/3.3.0/gems/sentry-ruby-5.21.0/lib/sentry/envelope/item.rb:41:in `serialize',
/app/vendor/bundle/ruby/3.3.0/gems/sentry-ruby-5.21.0/lib/sentry/transport.rb:74:in `block in serialize_envelope',
/app/vendor/bundle/ruby/3.3.0/gems/sentry-ruby-5.21.0/lib/sentry/transport.rb:73:in `each',
/app/vendor/bundle/ruby/3.3.0/gems/sentry-ruby-5.21.0/lib/sentry/transport.rb:73:in `serialize_envelope',
/app/vendor/bundle/ruby/3.3.0/gems/sentry-ruby-5.21.0/lib/sentry/transport.rb:61:in `send_envelope',
/app/vendor/bundle/ruby/3.3.0/gems/sentry-ruby-5.21.0/lib/sentry/transport.rb:51:in `send_event',
/app/vendor/bundle/ruby/3.3.0/gems/sentry-ruby-5.21.0/lib/sentry/client.rb:208:in `send_event',
/app/vendor/bundle/ruby/3.3.0/gems/sentry-ruby-5.21.0/lib/sentry/client.rb:271:in `block in dispatch_background_event',
/app/vendor/bundle/ruby/3.3.0/gems/sentry-rails-5.21.0/lib/sentry/rails/background_worker.rb:6:in `_perform',
/app/vendor/bundle/ruby/3.3.0/gems/sentry-ruby-5.21.0/lib/sentry/background_worker.rb:56:in `block in perform',
/app/vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:359:in `run_task',
/app/vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:350:in `block (3 levels) in create_worker',
<internal:kernel>:187:in `loop',
/app/vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:341:in `block (2 levels) in create_worker',
/app/vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:340:in `catch',
/app/vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:340:in `block in create_worker'

Reproduction Steps

Use Sentry with json gem version 2.8.0+

Expected Behavior

Normal use should not produce deprecation warnings.

Actual Behavior

Deprecation warning printed

Ruby Version

3.3.6

SDK Version

5.21.0

Integration and Its Version

No response

Sentry Config

No response