Skip to content

Commit ffffce9

Browse files
authored
Fix: Get connection from connection_pool instead of ActiveRecord::Base.connection (#2278)
1 parent 5612850 commit ffffce9

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## Unreleased
2+
3+
### Bug Fixes
4+
5+
- Don't instantiate connection in `ActiveRecordSubscriber` ([#2278](https://github.com/getsentry/sentry-ruby/pull/2278))
6+
17
## 5.17.1
28

39
### Bug Fixes

sentry-rails/lib/sentry/rails/tracing/active_record_subscriber.rb

+1-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ def self.subscribe!
2121
span.set_data(:connection_id, payload[:connection_id])
2222

2323
# we fallback to the base connection on rails < 6.0.0 since the payload doesn't have it
24-
base_connection = ActiveRecord::Base.connection
25-
connection ||= base_connection if payload[:connection_id] == base_connection.object_id
24+
connection ||= ActiveRecord::Base.connection_pool.connections.find { |conn| conn.object_id == payload[:connection_id] }
2625
end
2726

2827
next unless connection

0 commit comments

Comments
 (0)