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

Include the connection ID in ActiveRecord breadcrumbs on new version of Rails #655

Merged
merged 1 commit into from
Mar 26, 2021
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
Changelog
=========

## TBD

### Enhancements

* Classify `ActionDispatch::Http::MimeNegotiation::InvalidType` as info severity level
| [#654](https://github.com/bugsnag/bugsnag-ruby/pull/654)

### Fixes

* Include `connection_id` in ActiveRecord breadcrumb metadata on new versons of Rails
| [#655](https://github.com/bugsnag/bugsnag-ruby/pull/655)

## 6.19.0 (6 January 2021)

### Enhancements
Expand Down
2 changes: 2 additions & 0 deletions lib/bugsnag/integrations/rails/rails_breadcrumbs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ module Bugsnag::Rails
:type => Bugsnag::Breadcrumbs::PROCESS_BREADCRUMB_TYPE,
:allowed_data => [
:name,
# :connection_id is no longer provided in Rails 6.1+ but we can get it
# from the :connection key of the event instead
:connection_id,
:cached
]
Expand Down
17 changes: 14 additions & 3 deletions lib/bugsnag/integrations/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,21 @@ def event_subscription(event)
filtered_data = data.slice(*event[:allowed_data])
filtered_data[:event_name] = event[:id]
filtered_data[:event_id] = event_id
if event[:id] == "sql.active_record" && data.key?(:binds)
binds = data[:binds].each_with_object({}) { |bind, output| output[bind.name] = '?' if defined?(bind.name) }
filtered_data[:binds] = JSON.dump(binds) unless binds.empty?

if event[:id] == "sql.active_record"
if data.key?(:binds)
binds = data[:binds].each_with_object({}) { |bind, output| output[bind.name] = '?' if defined?(bind.name) }
filtered_data[:binds] = JSON.dump(binds) unless binds.empty?
end

# Rails < 6.1 included connection_id in the event data, but now
# includes the connection object instead
if data.key?(:connection) && !data.key?(:connection_id)
imjoehaines marked this conversation as resolved.
Show resolved Hide resolved
# the connection ID is the object_id of the connection object
filtered_data[:connection_id] = data[:connection].object_id
end
end

Bugsnag.leave_breadcrumb(
event[:message],
filtered_data,
Expand Down