Skip to content

Commit

Permalink
Fix: Get connection from connection_pool instead of ActiveRecord::Bas…
Browse files Browse the repository at this point in the history
…e.connection (#2278)
  • Loading branch information
Iwaide committed Mar 20, 2024
1 parent 5612850 commit ffffce9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 6 additions & 0 deletions 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
Expand Down
Expand Up @@ -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
Expand Down

0 comments on commit ffffce9

Please sign in to comment.