module Statue::SidekiqStatistics
This module simplifies the job statistics tracking using Statue
-
Provides a
SidekiqMiddleware
(to track performance and latency) -
Provides a method for tracking other middleware events (eg. throttling, deadline)
The current set of metrics are:
-
count job.<queue>.<job_name>.(success|failure): depending if the job succeeded or failed
-
count job.<queue>.<job_name>.throttled: only if the job was throttled by sidekiq-throttler
-
count job.<queue>.<job_name>.overdue: only if the deadline from run_deadline_middleware was reached
-
count job.<queue>.<job_name>.retry: only if the job corresponds to a retry for a previously failed job
-
duration job.<queue>.<job_name>.latency: time difference between now and when the job last entered the queue
-
duration job.<queue>.<job_name>: job run duration (reported only if the job doesn't fail)
Public Class Methods
# File lib/statue/sidekiq_statistics.rb, line 23 def self.count_event(event, worker, message) Statue.report_increment("#{job_metric_name(worker, message)}.#{event}") end
# File lib/statue/sidekiq_statistics.rb, line 27 def self.job_metric_name(worker, message) job_name = if worker.respond_to?(:job_name) worker.job_name(*message["args"]) elsif message.dig("args", 0, "job_class") # search for the class name that resides in the message received message.dig("args", 0, "job_class") else worker.class.name.gsub(/::/, "-") end "job.#{message["queue"]}.#{job_name}" end