Sha256: 0c4606963a47cc04c51ce073fd0efd745a9cea30847f28f0dc6392fc0394cf68

Contents?: true

Size: 520 Bytes

Versions: 7

Compression:

Stored size: 520 Bytes

Contents

require 'sidekiq'
require 'sidekiq_queue_metrics/storage'

module Sidekiq::QueueMetrics
  class Monitor
    def monitor(queue)
      stats = existing_stats
      stats[queue] ||= {}

      if stats[queue][status_counter].nil?
        stats[queue][status_counter] = 1
      else
        stats[queue][status_counter] += 1
      end

      Storage.set_stats(stats.to_json)
    end

    protected
    def status_counter
    end

    private
    def existing_stats
      JSON.load(Storage.get_stats || '{}')
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
sidekiq_queue_metrics-2.1.1 lib/sidekiq_queue_metrics/monitor/monitor.rb
sidekiq_queue_metrics-2.1 lib/sidekiq_queue_metrics/monitor/monitor.rb
sidekiq_queue_metrics-2.0 lib/sidekiq_queue_metrics/monitor/monitor.rb
sidekiq_queue_metrics-1.0 lib/sidekiq_queue_metrics/monitor/monitor.rb
sidekiq_queue_metrics-0.0.4 lib/sidekiq_queue_metrics/monitor/monitor.rb
sidekiq_queue_metrics-0.0.3 lib/sidekiq_queue_metrics/monitor/monitor.rb
sidekiq_queue_metrics-0.0.2 lib/sidekiq_queue_metrics/monitor/monitor.rb