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:
returning false from a callback will discard the breadcrumb and stop any subsequent callbacks from running
any errors raised by a callback will be rescued and logged. Any subsequent callbacks will still be run and the breadcrumb will not be discarded
any object responding to #call is a valid callback
Changeset
add Bugsnag::Breadcrumbs::OnBreadcrumbCallbackList which manages the callbacks and can call them with the correct semantics
add Bugnsag#add_on_breadcrumb, Bugnsag#remove_on_breadcrumb, Bugnsag#add_on_breadcrumb and Bugnsag::Configuration#remove_on_breadcrumb
modified Bugsnag#leave_breadcrumb to call the new callbacks via the OnBreadcrumbCallbackList
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
Goal
Adds
on_breadcrumb
callbacks, which will replacebefore_breadcrumb_callbacks
in the next major releaseThe API is similar to
on_error
callbacks:The semantics also follow
on_error
callbacks:false
from a callback will discard the breadcrumb and stop any subsequent callbacks from running#call
is a valid callbackChangeset
Bugsnag::Breadcrumbs::OnBreadcrumbCallbackList
which manages the callbacks and can call them with the correct semanticsBugnsag#add_on_breadcrumb
,Bugnsag#remove_on_breadcrumb
,Bugnsag#add_on_breadcrumb
andBugnsag::Configuration#remove_on_breadcrumb
Bugsnag#leave_breadcrumb
to call the new callbacks via theOnBreadcrumbCallbackList
Testing
This is tested both in tests specifically for
OnBreadcrumbCallbackList
to ensure the semantics are correct and as part of the main set ofBugsnag
tests to ensure they are called when leaving a breadcrumbThere are big whitespace changes in
bugsnag_spec.rb
to splitbefore_breadcrumb_callbacks
into their owndescribe
, so it's easier to review that file by ignoring whitespace