Class: PrometheusExporter::Instrumentation::GoodJob

Inherits:
PeriodicStats
  • Object
show all
Defined in:
lib/prometheus_exporter/instrumentation/good_job.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/good_job.rb', line 6

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

  worker_loop do
    client.send_json(good_job_collector.collect)
  end

  super
end

Instance Method Details

#collectObject



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/prometheus_exporter/instrumentation/good_job.rb', line 17

def collect
  {
    type: "good_job",
    scheduled: ::GoodJob::Job.scheduled.size,
    retried: ::GoodJob::Job.retried.size,
    queued: ::GoodJob::Job.queued.size,
    running: ::GoodJob::Job.running.size,
    finished: ::GoodJob::Job.finished.size,
    succeeded: ::GoodJob::Job.succeeded.size,
    discarded: ::GoodJob::Job.discarded.size
  }
end