Introduce active_job_report_on_retry_error #2617
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
⚡ TL;DR
active_job_report_after_job_retries
introduced in add report_after_job_retries support for ActiveJob #2500 is replaced byactive_job_report_on_retry_error
⏳ Longer explanation
Plot twist: the
active_job_report_after_retries
turned out to be problematic because if we want to report on each retry failure too, then we must always report on the last retry in the perform patch.Previously the retry_stopped handler would do the reporting of the final attempt error and the perform patch would skip reporting to avoid duped reports, but that does not work when reporting on each retry error is meant to work too, because there is no way to tell whether the final attempt was already reported by the retry_stopped handler or not. This means that when a job failed but there was no retry, and the reporting on retry errors is turned on, then we would not get any report because the perform patch would skip reporting since reporting on retry errors is turned on.
This is really confusing, I know!
Luckily, this PR changes our original new setting to become
active_job_report_on_retry_error
which is a simpler solution since it only adds new logic for reporting errors on each retry and stays away from the original final-failure handling implemented in the perform patch.This setting is disabled by default because it is the original behavior of the SDK and we don't want to change it in a patch release.
Once you enable
active_job_report_on_retry_error
, Sentry will be reporting exceptions on each job retry error usingenqueue_retry.active_job
handler, and the final (last retry attempt) failure will be reported by the perform patch.There is no other way of doing this because of how ActiveJob works. We cannot use
around_perform
as described here 9303b9a and there are no AS notifications about errors at the moment that we could leverage except the one for retries.In a future Rails release there errors will be reported using an error reported that we'll be able to hook into though, so we will most likely have a dedicated handling logic for future Rails versions eventually.
Refs #2500
Refs #2598
Refs #2597