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
# 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 { client.send_json(good_job_collector.collect) }

  super
end

Instance Method Details

#collectObject



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

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