Class: Bigcommerce::Prometheus::Collectors::Resque

Inherits:
Base
  • Object
show all
Defined in:
lib/bigcommerce/prometheus/collectors/resque.rb

Overview

Collect metrics to push to the server type collector

Instance Method Summary collapse

Methods inherited from Base

#initialize, #run, start, stop

Constructor Details

This class inherits a constructor from Bigcommerce::Prometheus::Collectors::Base

Instance Method Details

#collect(metrics = {}) ⇒ Hash

Parameters:

  • metrics (Hash) (defaults to: {})

Returns:

  • (Hash)


29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/bigcommerce/prometheus/collectors/resque.rb', line 29

def collect(metrics = {})
  info = ::Resque.info

  metrics[:environment] = info[:environment].to_s
  metrics[:workers_total] = info[:workers].to_i
  metrics[:jobs_failed_total] = info[:failed].to_i
  metrics[:jobs_pending_total] = info[:pending].to_i
  metrics[:jobs_processed_total] = info[:processed].to_i
  metrics[:queues_total] = info[:queues].to_i
  metrics[:queues] = queue_sizes
  metrics
end

#queue_sizesObject



42
43
44
45
46
47
48
# File 'lib/bigcommerce/prometheus/collectors/resque.rb', line 42

def queue_sizes
  queues = {}
  ::Resque.queues.each do |queue|
    queues[queue.to_sym] = ::Resque.size(queue)
  end
  queues
end