Sha256: 4139af02071e697d90ef4b8120446692a78eca3dcec10a4608e0813cdd843640

Contents?: true

Size: 890 Bytes

Versions: 10

Compression:

Stored size: 890 Bytes

Contents

# frozen_string_literal: true

module PrometheusExporter::Instrumentation
  class SidekiqStats < PeriodicStats
    def self.start(client: nil, frequency: 30)
      client ||= PrometheusExporter::Client.default
      sidekiq_stats_collector = new

      worker_loop do
        client.send_json(sidekiq_stats_collector.collect)
      end

      super
    end

    def collect
      {
        type: 'sidekiq_stats',
        stats: collect_stats
      }
    end

    def collect_stats
      stats = ::Sidekiq::Stats.new
      {
        'dead_size' => stats.dead_size,
        'enqueued' => stats.enqueued,
        'failed' => stats.failed,
        'processed' => stats.processed,
        'processes_size' => stats.processes_size,
        'retry_size' => stats.retry_size,
        'scheduled_size' => stats.scheduled_size,
        'workers_size' => stats.workers_size,
      }
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
prometheus_exporter-2.1.1 lib/prometheus_exporter/instrumentation/sidekiq_stats.rb
prometheus_exporter-2.1.0 lib/prometheus_exporter/instrumentation/sidekiq_stats.rb
prometheus_exporter-2.0.8 lib/prometheus_exporter/instrumentation/sidekiq_stats.rb
prometheus_exporter-2.0.7 lib/prometheus_exporter/instrumentation/sidekiq_stats.rb
prometheus_exporter-2.0.6 lib/prometheus_exporter/instrumentation/sidekiq_stats.rb
prometheus_exporter-2.0.5 lib/prometheus_exporter/instrumentation/sidekiq_stats.rb
prometheus_exporter-2.0.4 lib/prometheus_exporter/instrumentation/sidekiq_stats.rb
prometheus_exporter-2.0.3 lib/prometheus_exporter/instrumentation/sidekiq_stats.rb
prometheus_exporter-2.0.2 lib/prometheus_exporter/instrumentation/sidekiq_stats.rb
prometheus_exporter-2.0.1 lib/prometheus_exporter/instrumentation/sidekiq_stats.rb