-
Notifications
You must be signed in to change notification settings - Fork 993
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
Migrate from sentry-raven
to sentry-ruby
#8818
Conversation
cf68e11
to
970d210
Compare
Awesome, it was about time! See #7553 for previous art. This PR can supersede that one but maybe you find something useful in the code/comments there! |
9c2a457
to
fe8e3f2
Compare
ce2bfe8
to
ca42235
Compare
if (exception = hint[:exception]) | ||
exception.raven_context.each do |key, value| | ||
event.send("#{key}=", value) | ||
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.
Copied from the migration guide here: https://docs.sentry.io/platforms/ruby/migration/#exceptionraven_context
@@ -39,7 +41,8 @@ | |||
swift | |||
)}x | |||
|
|||
config.processors += [ExceptionSanitizer] | |||
config.before_send = ->(event, hint) { Dependabot::Sentry::Processor.process_chain(event, hint) } | |||
config.propagate_traces = false |
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.
This prevents Sentry adding Sentry-Trace
and Baggage
headers by default to all outgoing requests. It's designed to make it easier to do distributed tracing between microservices or frontend/backend. As we don't have that architecture, and it currently breaks our smoke test cache, I've chosen to disable it by default.
If we want to get this distributed trace information, we'll need to ignore these headers in our updater proxy.
References:
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.
I think disabling is the right call as Dependabot makes most calls to external endpoints that don't care about our tracing.
tags: tags.merge({ | ||
"gh.dependabot_api.update_job.id": job&.id, | ||
"gh.dependabot_api.update_config.package_manager": job&.package_manager, | ||
"gh.repo.is_private": job&.repo_private? | ||
}.compact), | ||
extra: extra.merge({ | ||
dependency_name: dependency&.name, | ||
dependency_group: dependency_group&.name | ||
}.compact), | ||
user: { | ||
id: job&.repo_owner |
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.
capture_exception
now expects kwargs
instead of a Hash
. See https://github.com/getsentry/sentry-ruby/blob/7666c94f1f2671e4c42cd8c4a6991e3ce7da56f9/sentry-ruby/lib/sentry-ruby.rb#L394-L401
# typed: strong | ||
# frozen_string_literal: true | ||
|
||
module Sentry |
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.
tapioca gem sentry-ruby
generates an empty file, so this is minimal handwritten types for our uses.
@@ -39,7 +41,8 @@ | |||
swift | |||
)}x | |||
|
|||
config.processors += [ExceptionSanitizer] | |||
config.before_send = ->(event, hint) { Dependabot::Sentry::Processor.process_chain(event, hint) } |
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.
config.processors
has been removed in favour of a lambda before_send
. I've replicated the behaviour by using a reducer to call processors in order.
I had to migrate raven_context
to a custom processor as well, because raven_context
is no longer attached to events by default.
ca42235
to
85251aa
Compare
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.
Fantastic job! ❤️
Thanks @JamieMagee for tackling this, one less hanging TODO that I feel bad about not having the time to finish 😊 plus I was always annoyed that Dependabot was relying on an EOL'd library. Reading through this PR was a lot of fun 🎉 because it answered several of my questions from #7553. In case you didn't see this note from my PR:
I suspect this change is harmless, but still, might be worth double-checking when this gets deployed, just in case. More details here, including how to preserve the old behavior through configuration if necessary. |
This migrates from the deprecated
sentry-raven
gem to the replacementsentry-ruby
gem.sentry-raven
was deprecated in March 2021.The changes mostly follow the Sentry migration guide. The largest changes were around event processors. Previously,
sentry-raven
allowed you to inherit fromRaven::Processor
and pass it toprocessors
during configuration. Insentry-ruby
that has been replaced withbefore_send
which accepts a single lambda. I've recreated the same behaviour by using a reducer to apply processors consecutively. See the "scrubbing sensitive data" and "Filtering for Ruby" documentation for more information.Once this is merged, it opens up the possibility of using the
sentry-opentelemetry
gem as well.