Module: G5PromRails::SidekiqApplicationMetrics

Extended by:
ActiveSupport::Concern
Included in:
MetricsContainer
Defined in:
lib/g5_prom_rails/sidekiq_application_metrics.rb

Instance Method Summary collapse

Instance Method Details

#initialize_sidekiq_applicationObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/g5_prom_rails/sidekiq_application_metrics.rb', line 6

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_statisticsObject



28
29
30
31
32
33
34
35
36
37
# File 'lib/g5_prom_rails/sidekiq_application_metrics.rb', line 28

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