Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Get connection from connection_pool instead of ActiveRecord::Base.connection #2278

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 @@
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] }

Check warning on line 24 in sentry-rails/lib/sentry/rails/tracing/active_record_subscriber.rb

View check run for this annotation

Codecov / codecov/patch

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

Added line #L24 was not covered by tests
end

next unless connection
Expand Down