Class: SidekiqStatsJob

Inherits:
Object
  • Object
show all
Includes:
Sidekiq::Job
Defined in:
app/sidekiq/sidekiq_stats_job.rb

Constant Summary collapse

METRIC_NAMES =
%w[
  processed
  failed
  scheduled_size
].freeze

Instance Method Summary collapse

Instance Method Details

#performObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/sidekiq/sidekiq_stats_job.rb', line 14

def perform
  info = Sidekiq::Stats.new

  self.class::METRIC_NAMES.each do |method, stat|
    stat ||= method

    StatsD.gauge "shared.sidekiq.stats.#{stat}", info.send(method)
  end

  working = Sidekiq::ProcessSet.new.select { |p| p[:busy] == 1 }.count
  StatsD.gauge 'shared.sidekiq.stats.working', working

  retry_size = Sidekiq::RetrySet.new.size
  StatsD.gauge 'shared.sidekiq.stats.retry_size', retry_size

  info.queues.each do |name, size|
    StatsD.gauge "shared.sidekiq.#{name}.size", size
  end
end