diff --git a/CHANGELOG.md b/CHANGELOG.md index a68fd45c5..ece53ce61 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## Unreleased + +### Bug Fixes + +- Don't instantiate connection in `ActiveRecordSubscriber` ([#2278](https://github.com/getsentry/sentry-ruby/pull/2278)) + ## 5.17.1 ### Bug Fixes diff --git a/sentry-rails/lib/sentry/rails/tracing/active_record_subscriber.rb b/sentry-rails/lib/sentry/rails/tracing/active_record_subscriber.rb index 3eeff2db6..ab25273a9 100644 --- a/sentry-rails/lib/sentry/rails/tracing/active_record_subscriber.rb +++ b/sentry-rails/lib/sentry/rails/tracing/active_record_subscriber.rb @@ -21,8 +21,7 @@ def self.subscribe! span.set_data(:connection_id, payload[:connection_id]) # we fallback to the base connection on rails < 6.0.0 since the payload doesn't have it - base_connection = ActiveRecord::Base.connection - connection ||= base_connection if payload[:connection_id] == base_connection.object_id + connection ||= ActiveRecord::Base.connection_pool.connections.find { |conn| conn.object_id == payload[:connection_id] } end next unless connection