Class: PrometheusExporter::Instrumentation::Resque

Inherits:
PeriodicStats
  • Object
show all
Defined in:
lib/prometheus_exporter/instrumentation/resque.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from PeriodicStats

started?, stop, worker_loop

Class Method Details

.start(client: nil, frequency: 30) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/prometheus_exporter/instrumentation/resque.rb', line 6

def self.start(client: nil, frequency: 30)
  resque_collector = new
  client ||= PrometheusExporter::Client.default

  worker_loop do
    client.send_json(resque_collector.collect)
  end

  super
end

Instance Method Details

#collectObject



17
18
19
20
21
22
# File 'lib/prometheus_exporter/instrumentation/resque.rb', line 17

def collect
  metric = {}
  metric[:type] = "resque"
  collect_resque_stats(metric)
  metric
end

#collect_resque_stats(metric) ⇒ Object



24
25
26
27
28
29
30
31
32
33
# File 'lib/prometheus_exporter/instrumentation/resque.rb', line 24

def collect_resque_stats(metric)
  info = ::Resque.info

  metric[:processed_jobs] = info[:processed]
  metric[:failed_jobs] = info[:failed]
  metric[:pending_jobs] = info[:pending]
  metric[:queues] = info[:queues]
  metric[:worker] = info[:workers]
  metric[:working] = info[:working]
end