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.



26
27
28
# File 'lib/sidekiq/api.rb', line 26

def initialize
  fetch_stats_fast!
end

Instance Method Details

#dead_sizeObject



46
47
48
# File 'lib/sidekiq/api.rb', line 46

def dead_size
  stat :dead_size
end

#default_queue_latencyObject



62
63
64
# File 'lib/sidekiq/api.rb', line 62

def default_queue_latency
  stat :default_queue_latency
end

#enqueuedObject



50
51
52
# File 'lib/sidekiq/api.rb', line 50

def enqueued
  stat :enqueued
end

#failedObject



34
35
36
# File 'lib/sidekiq/api.rb', line 34

def failed
  stat :failed
end

#processedObject



30
31
32
# File 'lib/sidekiq/api.rb', line 30

def processed
  stat :processed
end

#processes_sizeObject



54
55
56
# File 'lib/sidekiq/api.rb', line 54

def processes_size
  stat :processes_size
end

#queuesObject



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

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



42
43
44
# File 'lib/sidekiq/api.rb', line 42

def retry_size
  stat :retry_size
end

#scheduled_sizeObject



38
39
40
# File 'lib/sidekiq/api.rb', line 38

def scheduled_size
  stat :scheduled_size
end

#workers_sizeObject



58
59
60
# File 'lib/sidekiq/api.rb', line 58

def workers_size
  stat :workers_size
end