Commit e6e11d90 authored by Robert Speicher's avatar Robert Speicher

Custom fingerprint frequent, non-actionable exceptions

parent 5c215606
...@@ -2,6 +2,21 @@ ...@@ -2,6 +2,21 @@
module Gitlab module Gitlab
module ErrorTracking module ErrorTracking
# Exceptions in this group will receive custom Sentry fingerprinting
CUSTOM_FINGERPRINTING = %w[
Acme::Client::Error::BadNonce
Acme::Client::Error::NotFound
Acme::Client::Error::RateLimited
Acme::Client::Error::Timeout
Acme::Client::Error::UnsupportedOperation
ActiveRecord::ConnectionTimeoutError
ActiveRecord::QueryCanceled
Gitlab::RequestContext::RequestDeadlineExceeded
GRPC::DeadlineExceeded
JIRA::HTTPError
Rack::Timeout::RequestTimeoutException
].freeze
class << self class << self
def configure def configure
Raven.configure do |config| Raven.configure do |config|
...@@ -14,8 +29,7 @@ module Gitlab ...@@ -14,8 +29,7 @@ module Gitlab
# Sanitize authentication headers # Sanitize authentication headers
config.sanitize_http_headers = %w[Authorization Private-Token] config.sanitize_http_headers = %w[Authorization Private-Token]
config.tags = { program: Gitlab.process_name } config.tags = { program: Gitlab.process_name }
# Debugging for https://gitlab.com/gitlab-org/gitlab-foss/issues/57727 config.before_send = method(:before_send)
config.before_send = method(:add_context_from_exception_type)
end end
end end
...@@ -92,6 +106,13 @@ module Gitlab ...@@ -92,6 +106,13 @@ module Gitlab
private private
def before_send(event, hint)
event = add_context_from_exception_type(event, hint)
event = custom_fingerprinting(event, hint)
event
end
def process_exception(exception, sentry: false, logging: true, extra:) def process_exception(exception, sentry: false, logging: true, extra:)
exception.try(:sentry_extra_data)&.tap do |data| exception.try(:sentry_extra_data)&.tap do |data|
extra = extra.merge(data) if data.is_a?(Hash) extra = extra.merge(data) if data.is_a?(Hash)
...@@ -142,6 +163,7 @@ module Gitlab ...@@ -142,6 +163,7 @@ module Gitlab
} }
end end
# Debugging for https://gitlab.com/gitlab-org/gitlab-foss/issues/57727
def add_context_from_exception_type(event, hint) def add_context_from_exception_type(event, hint)
if ActiveModel::MissingAttributeError === hint[:exception] if ActiveModel::MissingAttributeError === hint[:exception]
columns_hash = ActiveRecord::Base columns_hash = ActiveRecord::Base
...@@ -156,6 +178,18 @@ module Gitlab ...@@ -156,6 +178,18 @@ module Gitlab
event event
end end
# Group common, mostly non-actionable exceptions by type and message,
# rather than cause
def custom_fingerprinting(event, hint)
ex = hint[:exception]
return event unless CUSTOM_FINGERPRINTING.include?(ex.class.name)
event.fingerprint = ['{{ default }}', ex.class.name, ex.message]
event
end
end end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment