Class: SidekiqVigil::Check::QueueLatency

Inherits:
Base
  • Object
show all
Defined in:
lib/sidekiq_vigil/check/queue_latency.rb

Instance Attribute Summary

Attributes inherited from Base

#api, #clock, #logger, #options, #storage

Instance Method Summary collapse

Methods inherited from Base

#check_name, #execute, #initialize

Constructor Details

This class inherits a constructor from SidekiqVigil::Check::Base

Instance Method Details

#callObject



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/sidekiq_vigil/check/queue_latency.rb', line 6

def call
  api.queues(options.fetch(:queues, :all)).map do |queue|
    thresholds = options.merge(options.fetch(:per_queue, {}).fetch(queue.name, {}))
    latency = queue.latency.to_f
    threshold_result(
      target: queue.name,
      value: latency,
      warn: thresholds.fetch(:warn, 60),
      critical: thresholds.fetch(:critical, 300),
      message: "oldest job has waited #{latency.round(2)}s"
    )
  end
end