Skip to content

Commit

Permalink
Include the connection ID in AR breadcrumbs
Browse files Browse the repository at this point in the history
  • Loading branch information
imjoehaines committed Mar 26, 2021
1 parent 3573dc0 commit 70866ba
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
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
15 changes: 12 additions & 3 deletions lib/bugsnag/integrations/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,19 @@ 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

if data.key?(:connection) && !data.key?(:connection_id)
# get the connection ID from the connection object
filtered_data[:connection_id] = data[:connection].object_id
end
end

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

0 comments on commit 70866ba

Please sign in to comment.