Skip to content

Commit

Permalink
Sentry message
Browse files Browse the repository at this point in the history
  • Loading branch information
Robgra13 committed Oct 25, 2024
1 parent 35264bc commit 617268a
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions spec/sidekiq_poison_pill_remedy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@

enqueue_job

# there is no easy way to move the job to DeadSet, the process is rather complex
# we would ideally execute a single method call have a proper setup but in that case
# we need to use stub
allow_any_instance_of(Sidekiq::DeadSet).to receive(:find_job).with(enqueue_job).and_return(job)
allow(Sentry).to receive(:capture_message)
end

context "when the job is a poison pill in non-poison pill queue" do
Expand All @@ -32,6 +30,12 @@
call
end.to change { Sidekiq::Queue.new(default_queue).count }.from(1).to(0)
.and change { Sidekiq::Queue.new(poison_pill_queue).count }.from(0).to(1)

expect(Sentry).to have_received(:capture_message).with(
"MyJob was marked as `poison pill`, please create the job memory optimizations ticket timely",
level: :warning,
extra: hash_including(:job_item)
)
end
end

Expand All @@ -43,6 +47,12 @@
call
end.to avoid_changing { Sidekiq::Queue.new(default_queue).count }.from(0)
.and avoid_changing { Sidekiq::Queue.new(poison_pill_queue).count }.from(1)

expect(Sentry).to have_received(:capture_message).with(
"MyJob failed in the `poison_pill`, this means that it has to be urgently optimized on memory usage",
level: :critical,
extra: hash_including(:job_item)
)
end
end
end
Expand Down

0 comments on commit 617268a

Please sign in to comment.