allow ignoring error types from setting
test plan - existing errors should work - have a raven.yml - populate Settings.set('ignorable_errors', 'some error') - Change-Id: I1bbfc003506ef5f15aa7fdb887e0249c84f09c56 Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/232977 Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> Reviewed-by: Cody Cutrer <cody@instructure.com> Product-Review: Cody Cutrer <cody@instructure.com> QA-Review: Rob Orton <rob@instructure.com>
This commit is contained in:
parent
14da94d954
commit
ccc216ecfc
|
@ -43,6 +43,10 @@ if settings.present?
|
|||
end
|
||||
|
||||
Rails.configuration.to_prepare do
|
||||
Settings.get('ignorable_errors', '').split(',').each do |error|
|
||||
SentryProxy.register_ignorable_error(error)
|
||||
end
|
||||
|
||||
Canvas::Errors.register!(:sentry_notification) do |exception, data|
|
||||
setting = Setting.get("sentry_error_logging_enabled", 'true')
|
||||
SentryProxy.capture(exception, data) if setting == 'true'
|
||||
|
|
|
@ -20,7 +20,7 @@ require 'raven/base'
|
|||
class SentryProxy
|
||||
def self.capture(exception, data)
|
||||
if exception.is_a?(String) || exception.is_a?(Symbol)
|
||||
Raven.capture_message(exception.to_s, data)
|
||||
Raven.capture_message(exception.to_s, data) if reportable?(exception.to_s)
|
||||
else
|
||||
Raven.capture_exception(exception, data) if reportable?(exception)
|
||||
end
|
||||
|
@ -32,7 +32,7 @@ class SentryProxy
|
|||
# configure the sentry client in an initializer). This allows plugins and extensions
|
||||
# to register their own errors that they don't want to get reported to sentry
|
||||
def self.register_ignorable_error(error_class)
|
||||
@ignorable_errors = (self.ignorable_errors << error_class).uniq
|
||||
@ignorable_errors = (self.ignorable_errors << error_class.to_s).uniq
|
||||
end
|
||||
|
||||
def self.ignorable_errors
|
||||
|
@ -44,7 +44,11 @@ class SentryProxy
|
|||
end
|
||||
|
||||
def self.reportable?(exception)
|
||||
!ignorable_errors.include?(exception.class)
|
||||
if exception.is_a?(String)
|
||||
!ignorable_errors.include?(exception.to_s)
|
||||
else
|
||||
!ignorable_errors.include?(exception.class.to_s)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -52,11 +52,10 @@ describe SentryProxy do
|
|||
end
|
||||
end
|
||||
|
||||
|
||||
describe ".register_ignorable_error" do
|
||||
it "keeps track of errors we don't care about reporting" do
|
||||
SentryProxy.register_ignorable_error(MyCustomError)
|
||||
expect(SentryProxy.ignorable_errors).to include(MyCustomError)
|
||||
expect(SentryProxy.ignorable_errors).to include(MyCustomError.to_s)
|
||||
end
|
||||
|
||||
it "prevents the same error from being registered many times" do
|
||||
|
@ -64,6 +63,14 @@ describe SentryProxy do
|
|||
10.times { SentryProxy.register_ignorable_error(MyCustomError) }
|
||||
expect(SentryProxy.ignorable_errors.size).to eq(start_count + 1)
|
||||
end
|
||||
|
||||
it "registers strings to skip capture_message" do
|
||||
e = "Some Message"
|
||||
SentryProxy.register_ignorable_error(e)
|
||||
expect(Raven).to receive(:capture_message).never
|
||||
SentryProxy.capture(e, data)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue