Set event fingerprint for exceptions relating to external services

This commit is contained in:
Karina Kwiatek 2023-01-28 22:14:02 +01:00
parent 7d5104d09d
commit da9a170e67
1 changed files with 9 additions and 0 deletions

View File

@ -9,12 +9,21 @@ Sentry.init do |config|
# We recommend adjusting this value in production # We recommend adjusting this value in production
config.traces_sample_rate = 0.25 config.traces_sample_rate = 0.25
exception_fingerprints = {
Excon::Error::ServiceUnavailable => 'external-service',
Twitter::Error::InternalServerError => 'external-service',
}
config.before_send do |event, hint| config.before_send do |event, hint|
if hint[:exception].is_a?(Errors::Base) if hint[:exception].is_a?(Errors::Base)
# These are used for user-facing errors, not when something goes wrong # These are used for user-facing errors, not when something goes wrong
nil nil
end end
exception_class = hint[:exception].class.name
if exception_fingerprints.key?(exception_class)
event.fingerprint = [exception_fingerprints[hint[:exception].class.name]]
end
event event
end end
end end