bugsnag / bugsnag-ruby

BugSnag error monitoring & reporting software for rails, sinatra, rack and ruby
https://docs.bugsnag.com/platforms/ruby
MIT License
248 stars 173 forks source link

Add `on_breadcrumb` callbacks to replace `before_breadcrumb_callbacks` #686

Closed imjoehaines closed 3 years ago

imjoehaines commented 3 years ago

Goal

Adds on_breadcrumb callbacks, which will replace before_breadcrumb_callbacks in the next major release

The API is similar to on_error callbacks:

callback = proc do |breadcrumb|
  breadcrumb.metadata = { hello: 'world' }
end

Bugsnag.configure do |config|
  config.add_on_breadcrumb(callback)
  config.remove_on_breadcrumb(callback)
end

Bugsnag.add_on_breadcrumb(callback)
Bugsnag.remove_on_breadcrumb(callback)

The semantics also follow on_error callbacks:

Changeset

Testing

This is tested both in tests specifically for OnBreadcrumbCallbackList to ensure the semantics are correct and as part of the main set of Bugsnag tests to ensure they are called when leaving a breadcrumb

There are big whitespace changes in bugsnag_spec.rb to split before_breadcrumb_callbacks into their own describe, so it's easier to review that file by ignoring whitespace