5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/metrician/jobs/sidekiq_middleware.rb', line 5
def call(worker, _msg, _queue)
start = Time.now
yield
rescue
if Jobs.error?
Metrician.increment(Jobs::ERROR_METRIC)
if Jobs.job_specific?
Metrician.increment("#{Jobs::ERROR_METRIC}.job.#{Jobs.instrumentation_name(worker.class.name)}")
end
end
raise
ensure
if Jobs.run?
duration = Time.now - start
Metrician.gauge(Jobs::RUN_METRIC, duration)
if Jobs.job_specific?
Metrician.gauge("#{Jobs::RUN_METRIC}.job.#{Jobs.instrumentation_name(worker.class.name)}", duration)
end
end
end
|