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

Add Bugsnag#breadcrumbs getter #689

Merged
merged 1 commit into from Aug 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -14,6 +14,8 @@ Changelog
* Add `context` attribute to configuration, which will be used as the default context for events. Using this option will disable automatic context setting
| [#687](https://github.com/bugsnag/bugsnag-ruby/pull/687)
| [#688](https://github.com/bugsnag/bugsnag-ruby/pull/688)
* Add `Bugsnag#breadcrumbs` getter to fetch the current list of breadcrumbs
| [#689](https://github.com/bugsnag/bugsnag-ruby/pull/689)

### Fixes

Expand Down
11 changes: 11 additions & 0 deletions lib/bugsnag.rb
Expand Up @@ -326,6 +326,17 @@ def remove_on_breadcrumb(callback)
configuration.remove_on_breadcrumb(callback)
end

##
# Returns the current list of breadcrumbs
#
# This is a per-thread circular buffer, containing at most 'max_breadcrumbs'
# breadcrumbs
#
# @return [Bugsnag::Utility::CircularBuffer]
def breadcrumbs
configuration.breadcrumbs
end

##
# Returns the client's Cleaner object, or creates one if not yet created.
#
Expand Down
7 changes: 5 additions & 2 deletions lib/bugsnag/configuration.rb
Expand Up @@ -449,9 +449,12 @@ def max_breadcrumbs=(new_max_breadcrumbs)
end

##
# Returns the breadcrumb circular buffer
# Returns the current list of breadcrumbs
#
# @return [Bugsnag::Utility::CircularBuffer] a thread based circular buffer containing breadcrumbs
# This is a per-thread circular buffer, containing at most 'max_breadcrumbs'
# breadcrumbs
#
# @return [Bugsnag::Utility::CircularBuffer]
def breadcrumbs
request_data[:breadcrumbs] ||= Bugsnag::Utility::CircularBuffer.new(@max_breadcrumbs)
end
Expand Down
6 changes: 6 additions & 0 deletions spec/bugsnag_spec.rb
Expand Up @@ -521,4 +521,10 @@ module Kernel
}
end
end

describe "#breadcrumbs" do
it "returns the configuration's breadcrumb buffer" do
expect(Bugsnag.breadcrumbs).to be(Bugsnag.configuration.breadcrumbs)
end
end
end