Skip to content

Commit e580fe7

Browse files
gjtorikianrosa
authored andcommitted
Wrap polling within instrumentation
1 parent 7901a8e commit e580fe7

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

lib/solid_queue/processes/poller.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,12 @@ def shutdown
4545
end
4646

4747
def with_polling_volume
48-
if SolidQueue.silence_polling? && ActiveRecord::Base.logger
49-
ActiveRecord::Base.logger.silence { yield }
50-
else
51-
yield
48+
SolidQueue.instrument(:polling) do
49+
if SolidQueue.silence_polling? && ActiveRecord::Base.logger
50+
ActiveRecord::Base.logger.silence { yield }
51+
else
52+
yield
53+
end
5254
end
5355
end
5456
end

test/integration/instrumentation_test.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,21 @@ class InstrumentationTest < ActiveSupport::TestCase
3737
assert_event events.first, "claim", process_id: process.id, job_ids: jobs.map(&:id), claimed_job_ids: jobs.map(&:id), size: 3
3838
end
3939

40+
test "polling emits events" do
41+
3.times { StoreResultJob.perform_later(42) }
42+
43+
events = subscribed("polling.solid_queue") do
44+
worker = SolidQueue::Worker.new.tap(&:start)
45+
46+
wait_while_with_timeout!(3.seconds) { SolidQueue::ReadyExecution.any? }
47+
48+
worker.stop
49+
end
50+
51+
assert_equal 5, events.size
52+
events.each { |e| assert_event e, "polling" }
53+
end
54+
4055
test "stopping a worker with claimed executions emits release_claimed events" do
4156
StoreResultJob.perform_later(42, pause: SolidQueue.shutdown_timeout + 100.second)
4257
process = nil

0 commit comments

Comments
 (0)