class Sidekiq::Monitor::Stats

Public Instance Methods

job_metrics() click to toggle source
# File lib/sidekiq/monitor/stats.rb, line 35
def job_metrics
  Sidekiq::Workers.new.map do |process, thread, msg|
    job = Sidekiq::Job.new(msg['payload'])

    {
      process: process,
      thread:  thread,
      jid:     job.jid,
      queue:   msg['queue'],
      job:     job.display_class,
      run_at:  Time.at(msg['run_at'])
    }
  end
end
process_metrics() click to toggle source
# File lib/sidekiq/monitor/stats.rb, line 20
def process_metrics
  Sidekiq::ProcessSet.new.map do |process|
    {
      hostname:    process['hostname'],
      pid:         process['pid'],
      tag:         process['tag'],
      started_at:  Time.at(process['started_at']),
      queues:      process['queues'],
      labels:      process['labels'],
      concurrency: process['concurrency'],
      busy:        process['busy']
    }
  end
end
queue_metrics() click to toggle source
# File lib/sidekiq/monitor/stats.rb, line 11
def queue_metrics
  Sidekiq::Queue.all.each_with_object({}) do |queue, hash|
    hash[queue.name] = {
      backlog: queue.size,
      latency: queue.latency.to_i
    }
  end
end