-
Notifications
You must be signed in to change notification settings - Fork 2
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
[ECHO-1987] Add a Sentry error handler #68
Changes from all commits
89e4e20
f355983
cd502c2
358a076
4a79b05
cd9938b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module Eventboss | ||
module ErrorHandlers | ||
class Sentry | ||
def call(exception, context = {}) | ||
eventboss_context = { component: 'eventboss' } | ||
eventboss_context[:action] = context[:processor].class.to_s if context[:processor] | ||
|
||
::Sentry.with_scope do |scope| | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not really, it's optional plugin, which makes Sentry will be required only when it's added in configuration. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this still is a dependency on the gem - it uses Sentry API that is valid for the specific range of Sentry versions There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, but what if I use Rollbar, not a Sentry? My whole project would have Sentry downloaded and required when then. As this is plugin, we don't force you to that feature. Unfortunately, as gem creators, we don't have options for checking the dependency, so you should take care about it by yourself. In that case you probably have it in your decencies, because you have to have it configured. Only version validation is still missing. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see this that way - Sentry is clearly dependency here. Its compatibility needs to be ensured somewhere - either in the client app or the gem side. I see no harm that user needs to download all the gems related with our plugins if we decided to keep them within the repo - it's still better that leave things unsecured in hope that nothing will blow up :) We can still create some other gems like The third option would be to inform users that there's a hook for custom error handlers so that you can attach one if you want - in respect to your Gemfile. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is not a place for this
What I would suggest is to just simply pass lambda to
And dependency to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that anyway by default these files from As There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
That's fair point! I think we can proceed with class like this 👍 |
||
scope.set_tags( | ||
context.merge(eventboss_context) | ||
) | ||
::Sentry.capture_exception(exception) | ||
end | ||
end | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
require 'eventboss/error_handlers/logger' | ||
require 'eventboss/error_handlers/airbrake' | ||
require 'eventboss/error_handlers/rollbar' | ||
require 'eventboss/error_handlers/sentry' | ||
require 'eventboss/error_handlers/db_connection_drop_handler' | ||
require 'eventboss/error_handlers/db_connection_not_established_handler' | ||
require 'eventboss/error_handlers/non_existent_queue_handler' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module Eventboss | ||
VERSION = "1.8.0" | ||
VERSION = "1.8.1" | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
require 'spec_helper' | ||
|
||
describe Eventboss::ErrorHandlers::Sentry do | ||
module Sentry; end | ||
|
||
subject { described_class.new } | ||
|
||
let(:some_error) { double(class: StandardError) } | ||
let(:sentry_with_scope_mock) { double(class: ::Sentry) } | ||
|
||
context 'when receiving some exception' do | ||
|
||
it 'calls Sentry.capture_exception' do | ||
expect(::Sentry).to receive(:with_scope).and_yield(sentry_with_scope_mock) | ||
|
||
expect(sentry_with_scope_mock).to receive(:set_tags).with(hash_including({ component: 'eventboss' })) | ||
expect(::Sentry).to receive(:capture_exception).with(some_error) | ||
|
||
subject.call(some_error) | ||
end | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's copied since airbrake. It's not beneficial as the information is in processor param.