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

Breadcrumbs: Configuration updates #507

Merged
merged 9 commits into from
Dec 7, 2018

Conversation

Cawllec
Copy link
Contributor

@Cawllec Cawllec commented Dec 6, 2018

Goal

Update the Configuration class in order to support breadcrumbs.

@Cawllec Cawllec requested review from tobyhs, kellymason and a team December 6, 2018 17:17
@Cawllec
Copy link
Contributor Author

Cawllec commented Dec 6, 2018

This is a first iteration, without tests as of yet, so any reviews should be very quick.

@Cawllec Cawllec changed the base branch from breadcrumbs/base to breadcrumbs/breadcrumb-validator December 6, 2018 17:18

# Store max_breadcrumbs here instead of outputting breadcrumbs.max_items
# to avoid infinite recursion when creating breadcrumb buffer
@max_breadcrumbs = DEFAULT_MAX_BREADCRUMBS.clone
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DEFAULT_MAX_BREADCRUMBS is an integer, so you shouldn't need to clone it

@@ -36,6 +37,9 @@ class Configuration
attr_accessor :auto_capture_sessions
attr_accessor :track_sessions
attr_accessor :session_endpoint
attr_accessor :automatic_breadcrumb_types

attr_reader :max_breadcrumbs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're starting to adopt yardoc, it would be good to add documentation/comments to new methods that you add/create.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To keep things consistent, I was going to add Yardoc comments to new files, and keep existing files as they are, and raise a ticket to Yardoc the whole repo.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the sake of these actually getting written, i've added the yardoc comments now and will continue to in all the other changes.

@Cawllec Cawllec changed the title WIP: Breadcrumbs: Configuration updates Breadcrumbs: Configuration updates Dec 7, 2018
@@ -68,6 +75,12 @@ def initialize
self.notify_release_stages = nil
self.auto_capture_sessions = false
self.session_endpoint = DEFAULT_SESSION_ENDPOINT
# All valid breadcrumb types should be allowable initially
self.automatic_breadcrumb_types = Bugsnag::Breadcrumbs::VALID_BREADCRUMB_TYPES.clone
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you want dup here. If this isnt already frozen - we should freeze VALID_BREADCRUMB_TYPES

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes - and I'm adding the extra test to verify it is mutable.

##
# Stores callbacks that will be run before a breadcrumb is left
def before_breadcrumb_callbacks
@before_breadcrumb_callbacks ||= []
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems generally safer to initialize this in the constructor rather than lazily.


expect(buffer.to_a).to eq([1])
expect(second_buffer.to_a).to eq([2])
expect(buffer).to_not eq(second_buffer)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need this expect

end

describe "#automatic_breadcrumb_types" do
it "defaults to Bugsnag::Breadcrumbs::VALID_BREADCRUMB_TYPES" do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having some tests around being able to change this would be good

second_array = nil
Thread.new { second_array = subject.before_breadcrumb_callbacks; second_array << 2}.join

expect(first_array).to eql(second_array)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd drop this expectation

Copy link
Contributor

@snmaynard snmaynard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only one change required

@@ -37,6 +39,18 @@ class Configuration
attr_accessor :track_sessions
attr_accessor :session_endpoint

##
# @return [Array] array of strings indicating allowable automatic breadcrumb types
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should do [Array] and similar for others

@Cawllec Cawllec merged commit 1d98442 into breadcrumbs/breadcrumb-validator Dec 7, 2018
@Cawllec Cawllec deleted the breadcrumbs/configuration branch December 7, 2018 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants