-
-
Notifications
You must be signed in to change notification settings - Fork 523
add report_after_job_retries support for ActiveJob #2500
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
add report_after_job_retries support for ActiveJob #2500
Conversation
5ecd340 to
2be327a
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2500 +/- ##
==========================================
- Coverage 98.16% 96.99% -1.18%
==========================================
Files 128 126 -2
Lines 4847 4787 -60
==========================================
- Hits 4758 4643 -115
- Misses 89 144 +55
🚀 New features to boost your workflow:
|
79897d2 to
0ce620d
Compare
923d2d3 to
daee3d8
Compare
|
@solnic could you review and get this merged if you have time? |
|
@sl0thentr0py looking into it today |
solnic
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.
I've been digging into this and I don't think it works as expected and the test results are misleading. The spec actually ends up with 3 errors logged and I do not understand how it happens.
I added this pp statement to the spec:
context "when active_job_report_after_job_retries is true" do
before do
Sentry.configuration.rails.active_job_report_after_job_retries = true
end
after do
Sentry.configuration.rails.active_job_report_after_job_retries = false
end
it "reports 1 exception" do
assert_performed_jobs 3 do
FailedJobWithRetryOn.perform_later rescue nil
end
pp transport.events.first.exception.values
expect(Sentry::Rails::ActiveJobExtensions::SentryReporter)
.to have_received(:capture_exception)
.exactly(1).times
endand here's the output:
[#<Sentry::SingleExceptionInterface @type="FailedJob::TestError", @value="Boom! (FailedJob::TestError)", @module="FailedJob", @thread_id=12700, @mechanism=#<Sentry::Mechanism:0x0000ffff6340aa70 @type="rails", @handled=false>>,
#<Sentry::SingleExceptionInterface @type="FailedJob::TestError", @value="Boom! (FailedJob::TestError)", @module="FailedJob", @thread_id=12700, @mechanism=#<Sentry::Mechanism:0x0000ffff6340aa70 @type="rails", @handled=false>>,
#<Sentry::SingleExceptionInterface @type="FailedJob::TestError", @value="Boom! (FailedJob::TestError)", @module="FailedJob", @thread_id=12700, @mechanism=#<Sentry::Mechanism:0x0000ffff6340aa70 @type="rails", @handled=false>>]
Any ideas what is reporting these errors? It happens regardless if we use mocks or not.
|
@solnic which version of note that i only used it's also possible that the event publishing changed in between rails versions? if that's the case then i think we'd have to use the other approach i mentioned. also fwiw i can confirm that subscribing to this event and sending an error to sentry does perform as expected in rails 8.0.1 / ruby 3.4.1 (we're using this now in production at my workplace) so it's quite possible the issue lies in the test tooling (maybe |
It fails when I run both scenarios, passes when I run individually: This is latest rails and latest ruby. |
|
This is SO strange. When I run all tests from that file I get this: So it's like we get rspec's mocked calls count from all tests, and they just leak between the spec runs 🙈 |
|
Closing this in favor of #2573 where I fixed issues with specs and handling of AS notification |
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
Description
this pr adds
report_after_job_retriessupport toActiveJob(configured viaconfig.rails.active_job_report_after_job_retries).the easiest way to do this would have been to use retry_on in the base
ActiveJobclass (similar to here) but that's difficult to do properly which is (i think) why the currentActiveJobintegration doesn't do it.instead we can take advantage of the
retry_stopped.active_jobnotification that's published when a job runs out of retries. this makes our setup a single call toActiveSupport::Notifications.subscribe.fixes #2499