-
-
Notifications
You must be signed in to change notification settings - Fork 523
[active_job] support exception reporting only after last retry failed #2573
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
Conversation
4ab9ff9 to
b26b17a
Compare
90144c4 to
2fa01fc
Compare
2fa01fc to
d19050a
Compare
d19050a to
36c1176
Compare
|
Please ignore Danger here, it just fails to see that I added CHANGELOG entry. |
st0012
left a comment
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.
LGTM. Left some suggestions for tests.
| expect(Sentry::Rails::Tracing.subscribed_tracing_events).to be_empty | ||
| Sentry::Rails::Tracing.remove_active_support_notifications_patch | ||
|
|
||
| if defined?(Sentry::Rails::ActiveJobExtensions) |
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 with our current setup this will always be true?
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.
@st0012 not really, it may or may not be defined, depending on the order of loading files which is pretty much random 🙃
Otherwise specs would be failing randomly
36c1176 to
4e59569
Compare
Instructions and example for changelogPlease add an entry to Example: ## Unreleased
- [active_job] support exception reporting only after last retry failed ([#2573](https://github.com/getsentry/sentry-ruby/pull/2573))If none of the above apply, you can opt out of this check by adding |
dc38bb6 to
4e59569
Compare
|
Hi there, I came across this issue while trying to understand why I don't see any sentry issues from failing ActiveJob jobs until the final retry attempt. I'm using sentry-rails 5.23 and based on what this PR is trying to do, it seems like I should be seeing a Sentry issue on each retry. But I don't. That's a bit confusing to me, so I did a bit of investigation. The first thing I found is that the test setup is not representative of how ActiveJob typically runs in the real world. In particular, these lines do some subtle things that don't work well with assert_performed_jobs 3 do
FailedJobWithRetryOn.perform_later rescue nil
endWith the test adapter, So in this test scenario, the Sentry ActiveJob error handler will be called upon each retry, but I don't think that's what happens in the real world. If you change this test to look like this: - assert_performed_jobs 3 do
- FailedJobWithRetryOn.perform_later rescue nil
- end
+ FailedJobWithRetryOn.perform_later
+
+ perform_enqueued_jobs
+ perform_enqueued_jobs
+ perform_enqueued_jobs rescue nilThen you should see that only 1 call to the sentry error handler is made. This is more representative of how ActiveJob actually behaves because the retry handler will enqueue the job but not run it until the next call to But then this leads to my original question, does sentry-rails (even with this PR) capture an exception on every retry with ActiveJob? I don't quite see how this happens.
So I'm left a little confused, I'm guessing I've missed something. Perhaps some ActiveJob adapters behave differently (I'm using solid_queue)? |
|
@aburgel hey Alex, thanks for bringing this up. I'll look into this and re-visit this PR and related issue! |
This has been around the houses a little recently in [sentry-ruby]: - [#2500] - [#2573] - [#2617] but the TLDR seems to be we should enable a configuration option `active_job_report_on_retry_error` if we want to report errors when jobs are retried in `ActiveJob`. This enables the configuration. We want to do this, because it gives us better observablity of when things are going wrong (e.g we're not sending OTP emails due to errors). [sentry-ruby]: https://github.com/getsentry/sentry-ruby [#2500]: getsentry/sentry-ruby#2500 [#2573]: getsentry/sentry-ruby#2573 [#2617]: getsentry/sentry-ruby#2617
This is an updated version of #2500 which adds support for
active_job_report_after_job_retriesoption which makes reporting an exception upon a job failure to happen only on the last attempt retry failure.