Sha256: 7ed5c073eb5e5cda8eda46f22b653b5433e329429543c1ec4536942b98039046

Contents?: true

Size: 782 Bytes

Versions: 2

Compression:

Stored size: 782 Bytes

Contents

# frozen_string_literal: true

# collects stats from GoodJob
module PrometheusExporter::Instrumentation
  class GoodJob < PeriodicStats
    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

    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
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
prometheus_exporter-2.1.1 lib/prometheus_exporter/instrumentation/good_job.rb
prometheus_exporter-2.1.0 lib/prometheus_exporter/instrumentation/good_job.rb