Class: Sidekiq::Stats

Inherits:
Object
  • Object
show all
Defined in:
lib/sidekiq/api.rb

Overview

Retrieve runtime statistics from Redis regarding this Sidekiq cluster.

stat = Sidekiq::Stats.new
stat.processed

Defined Under Namespace

Classes: History

Instance Method Summary collapse

Constructor Details

#initializeStats

Returns a new instance of Stats.



28
29
30
# File 'lib/sidekiq/api.rb', line 28

def initialize
  fetch_stats_fast!
end

Instance Method Details

#dead_sizeObject



48
49
50
# File 'lib/sidekiq/api.rb', line 48

def dead_size
  stat :dead_size
end

#default_queue_latencyObject



64
65
66
# File 'lib/sidekiq/api.rb', line 64

def default_queue_latency
  stat :default_queue_latency
end

#enqueuedObject



52
53
54
# File 'lib/sidekiq/api.rb', line 52

def enqueued
  stat :enqueued
end

#failedObject



36
37
38
# File 'lib/sidekiq/api.rb', line 36

def failed
  stat :failed
end

#processedObject



32
33
34
# File 'lib/sidekiq/api.rb', line 32

def processed
  stat :processed
end

#processes_sizeObject



56
57
58
# File 'lib/sidekiq/api.rb', line 56

def processes_size
  stat :processes_size
end

#queuesObject



68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/sidekiq/api.rb', line 68

def queues
  Sidekiq.redis do |conn|
    queues = conn.sscan("queues").to_a

    lengths = conn.pipelined { |pipeline|
      queues.each do |queue|
        pipeline.llen("queue:#{queue}")
      end
    }

    array_of_arrays = queues.zip(lengths).sort_by { |_, size| -size }
    array_of_arrays.to_h
  end
end

#retry_sizeObject



44
45
46
# File 'lib/sidekiq/api.rb', line 44

def retry_size
  stat :retry_size
end

#scheduled_sizeObject



40
41
42
# File 'lib/sidekiq/api.rb', line 40

def scheduled_size
  stat :scheduled_size
end

#workers_sizeObject



60
61
62
# File 'lib/sidekiq/api.rb', line 60

def workers_size
  stat :workers_size
end