module G5PromRails::SidekiqApplicationMetrics

Public Instance Methods

initialize_sidekiq_application() click to toggle source
# File lib/g5_prom_rails/sidekiq_application_metrics.rb, line 7
def initialize_sidekiq_application
  @processed_counter = G5PromRails::SettableCounter.new(
    :sidekiq_processed,
    "jobs processed"
  )
  per_application.register(@processed_counter)
  @failed_counter = G5PromRails::SettableCounter.new(
    :sidekiq_failed,
    "jobs failed"
  )
  per_application.register(@failed_counter)

  @retry_gauge = per_application.gauge(
    :sidekiq_retry,
    "jobs to be retried"
  )
  @queues_gauge = per_application.gauge(
    :sidekiq_queued,
    "job queue lengths"
  )
end
update_sidekiq_statistics() click to toggle source
# File lib/g5_prom_rails/sidekiq_application_metrics.rb, line 29
def update_sidekiq_statistics
  stats = Sidekiq::Stats.new
  @processed_counter.set({}, stats.processed)
  @failed_counter.set({}, stats.failed)
  @retry_gauge.set({}, stats.retry_size)

  Sidekiq::Stats::Queues.new.lengths.each do |queue, length|
    @queues_gauge.set({ queue: queue }, length)
  end
end