Skip to content

Commit bfa8b49

Browse files
authored
Add new sidekiq config (#2581)
1 parent 3e97434 commit bfa8b49

File tree

4 files changed

+33
-0
lines changed

4 files changed

+33
-0
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
## Unreleased
22

3+
### Features
4+
5+
- Add new sidekiq config `report_only_dead_jobs` ([#2581](https://github.com/getsentry/sentry-ruby/pull/2581))
6+
37
### Bug Fixes
48

59
- Gracefully fail on malformed utf-8 breadcrumb message ([#2582](https://github.com/getsentry/sentry-ruby/pull/2582))

sentry-sidekiq/lib/sentry/sidekiq/configuration.rb

+4
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,12 @@ class Configuration
2121
# retry if it fails.
2222
attr_accessor :report_after_job_retries
2323

24+
# Only report jobs that don't have `dead: false` set in the job's `sidekiq_options`
25+
attr_accessor :report_only_dead_jobs
26+
2427
def initialize
2528
@report_after_job_retries = false
29+
@report_only_dead_jobs = false
2630
end
2731
end
2832
end

sentry-sidekiq/lib/sentry/sidekiq/error_handler.rb

+3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ def call(ex, context, sidekiq_config = nil)
3131
end
3232
end
3333

34+
# See if we want to ignore jobs that have dead: false
35+
return if Sentry.configuration.sidekiq.report_only_dead_jobs && context.dig(:job, "dead") == false
36+
3437
# Check if the retry count is below the attempt_threshold
3538
attempt_threshold = context.dig(:job, "attempt_threshold")
3639
if attempt_threshold && retryable?(context)

sentry-sidekiq/spec/sentry/sidekiq_spec.rb

+22
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,28 @@ def retry_last_failed_job
143143
end
144144
end
145145

146+
context "with config.report_only_dead_jobs = true" do
147+
before do
148+
Sentry.configuration.sidekiq.report_only_dead_jobs = true
149+
end
150+
151+
it "reports normal jobs" do
152+
worker = Class.new(SadWorker)
153+
worker.sidekiq_options retry: 0
154+
execute_worker(processor, worker)
155+
156+
expect(transport.events.count).to eq(1)
157+
end
158+
159+
it "does not report jobs with dead: false" do
160+
worker = Class.new(SadWorker)
161+
worker.sidekiq_options retry: 0, dead: false
162+
execute_worker(processor, worker)
163+
164+
expect(transport.events.count).to eq(0)
165+
end
166+
end
167+
146168
context "with config.report_after_job_retries = true" do
147169
before do
148170
Sentry.configuration.sidekiq.report_after_job_retries = true

0 commit comments

Comments
 (0)