Skip to content

Only report on non-handled ActiveJob retry #2677

@smathieu

Description

@smathieu

Problem Statement

We have jobs where we explicitly want to handle an exception and retry on.

e.g.

  class ExampleJob < ApplicationJob
    queue_as :high

    retry_on ActiveRecord::LockStatementTimeout
    
    def perform
      if rand(2) == 0
         # Exception we have explicitly handled using `retry_on`, only report if this is the last retry
         raise ActiveRecord::LockStatementTimeout
      else
         # Unhandled exception, always report to Sentry
         1 / 0 
      end
    end
end

If our case, we don't want to 'polute' Sentry with expected failures, like the lock not being available, unless we exhaust all retries.

As far as I under it, the only control we have over this is to set report_after_job_retries to false, but this will only report after all retries have been exhausted, which I think defaults to a 2 week time period.

Solution Brainstorm

I think report_after_job_retries = :only_unhandled should enable the described behavior.

Metadata

Metadata

Assignees

Projects

Status

Waiting for: Product Owner

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions