Class: Sidekiq::Stats
- Inherits:
-
Object
- Object
- Sidekiq::Stats
- Defined in:
- lib/sidekiq/api.rb
Defined Under Namespace
Classes: History
Instance Method Summary collapse
- #dead_size ⇒ Object
- #enqueued ⇒ Object
- #failed ⇒ Object
- #processed ⇒ Object
- #queues ⇒ Object
- #reset(*stats) ⇒ Object
- #retry_size ⇒ Object
- #scheduled_size ⇒ Object
Instance Method Details
#dead_size ⇒ Object
61 62 63 |
# File 'lib/sidekiq/api.rb', line 61 def dead_size Sidekiq.redis {|c| c.zcard('dead') } end |
#enqueued ⇒ Object
49 50 51 |
# File 'lib/sidekiq/api.rb', line 49 def enqueued queues.values.inject(&:+) || 0 end |
#failed ⇒ Object
10 11 12 |
# File 'lib/sidekiq/api.rb', line 10 def failed Sidekiq.redis { |conn| conn.get("stat:failed") }.to_i end |
#processed ⇒ Object
6 7 8 |
# File 'lib/sidekiq/api.rb', line 6 def processed Sidekiq.redis { |conn| conn.get("stat:processed") }.to_i end |
#queues ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/sidekiq/api.rb', line 28 def queues Sidekiq.redis do |conn| queues = conn.smembers('queues') lengths = conn.pipelined do queues.each do |queue| conn.llen("queue:#{queue}") end end i = 0 array_of_arrays = queues.inject({}) do |memo, queue| memo[queue] = lengths[i] i += 1 memo end.sort_by { |_, size| size } Hash[array_of_arrays.reverse] end end |
#reset(*stats) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/sidekiq/api.rb', line 14 def reset(*stats) all = %w(failed processed) stats = stats.empty? ? all : all & stats.flatten.compact.map(&:to_s) mset_args = [] stats.each do |stat| mset_args << "stat:#{stat}" mset_args << 0 end Sidekiq.redis do |conn| conn.mset(*mset_args) end end |