lib/sidekiq/instrument/middleware/server.rb in sidekiq-instrument-0.4.1 vs lib/sidekiq/instrument/middleware/server.rb in sidekiq-instrument-0.5.0
- old
+ new
@@ -3,14 +3,21 @@
module Sidekiq::Instrument
class ServerMiddleware
include Sidekiq::Instrument::MetricNames
def call(worker, job, queue, &block)
- StatsD.increment(metric_name(worker, 'dequeue'))
+ Statter.statsd.increment(metric_name(worker, 'dequeue'))
+ Statter.dogstatsd&.increment('sidekiq.dequeue', worker_dog_options(worker))
- StatsD.measure(metric_name(worker,'runtime'), &block)
+ start_time = Time.now
+ yield block
+ execution_time_ms = (Time.now - start_time) * 1000
+ Statter.statsd.measure(metric_name(worker, 'runtime'), execution_time_ms)
+ Statter.dogstatsd&.timing('sidekiq.runtime', execution_time_ms, worker_dog_options(worker))
rescue StandardError => e
- StatsD.increment(metric_name(worker, 'error'))
+ Statter.statsd.increment(metric_name(worker, 'error'))
+ Statter.dogstatsd&.increment('sidekiq.error', worker_dog_options(worker))
raise e
end
end
end
+