File tree Expand file tree Collapse file tree 4 files changed +19
-2
lines changed
sentry-ruby/spec/sentry/transport Expand file tree Collapse file tree 4 files changed +19
-2
lines changed Original file line number Diff line number Diff line change 2424
2525- Fixed a deprecation in ` sidekiq-ruby` error handler [# 2160](https://github.com/getsentry/sentry-ruby/pull/2160)
2626- Avoid invoking ActiveSupport ::BroadcastLogger if not defined [# 2169](https://github.com/getsentry/sentry-ruby/pull/2169)
27+ - Respect custom ` Delayed::Job.max_attempts` if it' s defined [#2176](https://github.com/getsentry/sentry-ruby/pull/2176)
2728
2829## 5.13.0
2930
Original file line number Diff line number Diff line change @@ -87,7 +87,8 @@ def self.report?(job)
8787
8888 # We use the predecessor because the job's attempts haven't been increased to the new
8989 # count at this point.
90- job . attempts >= Delayed ::Worker . max_attempts . pred
90+ max_attempts = job &.max_attempts &.pred || Delayed ::Worker . max_attempts . pred
91+ job . attempts >= max_attempts
9192 end
9293
9394 def self . finish_transaction ( transaction , status )
Original file line number Diff line number Diff line change @@ -143,6 +143,22 @@ def self.class_do_nothing
143143 expect ( transport . events . count ) . to eq ( 1 )
144144 end
145145
146+ # Default max_attemps is defined on Delayed::Worker.max_attempts == 25.
147+ # However, users can customize max_attempts on the job class, and DelayedJob
148+ # will respect that.
149+ # Sentry needs to report an exception if report_after_retries is true and
150+ # custom job-level max_attempts is reached.
151+ # See https://github.com/collectiveidea/delayed_job#custom-jobs
152+ it "reports exception after the job's custom max_attempts" do
153+ enqueued_job . update ( attempts : 2 )
154+ allow ( enqueued_job ) . to receive ( :max_attempts ) . and_return ( 3 )
155+
156+ expect do
157+ enqueued_job . invoke_job
158+ end . to raise_error ( ZeroDivisionError )
159+ expect ( transport . events . count ) . to eq ( 1 )
160+ end
161+
146162 it "skips report if not on the last retry" do
147163 enqueued_job . update ( attempts : 0 )
148164
Original file line number Diff line number Diff line change 275275 stub_request ( error_response )
276276
277277 expect { subject . send_data ( data ) } . to raise_error ( Sentry ::ExternalError , /error_in_header/ )
278-
279278 end
280279 end
281280 end
You can’t perform that action at this time.
0 commit comments