Skip to content

Commit

Permalink
add tags to sidekiq worker metrics (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
hkim3162 and hkim3163 authored May 12, 2023
1 parent e3e56e5 commit 0206e28
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/sidekiq/instrument/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Sidekiq
module Instrument
VERSION = '0.6.0'
VERSION = '0.6.1'
end
end
2 changes: 1 addition & 1 deletion lib/sidekiq/instrument/worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def send_worker_metrics

WorkerMetrics.workers_in_queue.each do |key, value|
Statter.statsd.gauge("shared.sidekiq.worker_metrics.inqueue.#{key}", value)
Statter.dogstatsd&.gauge("shared.sidekiq.worker_metrics.inqueue.#{key}", value)
Statter.dogstatsd&.gauge("shared.sidekiq.worker_metrics.inqueue", value, tags: ["worker:#{key}"])
end
end
end
Expand Down
8 changes: 6 additions & 2 deletions spec/sidekiq-instrument/worker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@
allow(dogstatsd).to receive(:gauge).with('sidekiq.queue.size', any_args).at_least(:once)
allow(dogstatsd).to receive(:gauge).with('sidekiq.queue.latency', any_args).at_least(:once)
expected_stats.each do |ex|
expect(dogstatsd).to receive(:gauge).with(ex, anything)
if ex.include?('shared.sidekiq.worker_metrics.inqueue')
expect(dogstatsd).to receive(:gauge).with(ex, anything, anything)
else
expect(dogstatsd).to receive(:gauge).with(ex, anything)
end
end
worker.perform
end
Expand Down Expand Up @@ -104,7 +108,7 @@
end

it_behaves_like 'worker behavior', %w[
shared.sidekiq.worker_metrics.inqueue.my_other_worker
shared.sidekiq.worker_metrics.inqueue
sidekiq.processed
sidekiq.workers
sidekiq.pending
Expand Down

0 comments on commit 0206e28

Please sign in to comment.