Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## Unreleased

### Bug Fixes 🐛

- (sidekiq) Report final attempt when retry limit is below `attempt_threshold` by @marcboquet in [#XXXX](https://github.com/getsentry/sentry-ruby/pull/XXXX)

## 6.5.0

### New Features ✨
Expand Down
4 changes: 3 additions & 1 deletion sentry-sidekiq/lib/sentry/sidekiq/error_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@ def call(ex, context, sidekiq_config = nil)
# attempt 2 - this is your first retry so retry_count is 0
# attempt 3 - you have retried once, retry_count is 1
attempt = retry_count.nil? ? 1 : retry_count.to_i + 2
# Cap at the final attempt so jobs with fewer retries than the threshold still report.
effective_threshold = [attempt_threshold, retry_limit(context, sidekiq_config) + 1].min

return if attempt < attempt_threshold
return if attempt < effective_threshold
end

Sentry::Sidekiq.capture_exception(
Expand Down
11 changes: 11 additions & 0 deletions sentry-sidekiq/spec/sentry/sidekiq_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,17 @@ def retry_last_failed_job
retry_last_failed_job
expect(transport.events.count).to eq(0)
end

it "reports on the final attempt when retry limit is below the threshold" do
worker = Class.new(SadWorker)
worker.sidekiq_options attempt_threshold: 3, retry: 1

execute_worker(processor, worker)
expect(transport.events.count).to eq(0)

retry_last_failed_job
expect(transport.events.count).to eq(1)
end
end

context "with config.report_only_dead_jobs = true" do
Expand Down
Loading