Class: OkComputer::SidekiqLatencyCheck

Inherits:
SizeThresholdCheck show all
Defined in:
lib/ok_computer/built_in_checks/sidekiq_latency_check.rb

Constant Summary

Constants inherited from Check

Check::CheckNotDefined

Instance Attribute Summary collapse

Attributes inherited from SizeThresholdCheck

#name, #size_proc, #threshold

Attributes inherited from Check

#failure_occurred, #message, #registrant_name, #time

Instance Method Summary collapse

Methods inherited from SizeThresholdCheck

#check

Methods inherited from Check

#<=>, #clear, #mark_failure, #mark_message, #run, #success?, #to_json, #to_text, #with_benchmarking

Constructor Details

#initialize(queue, threshold = 30) ⇒ SidekiqLatencyCheck

Public: Initialize a check for a backed-up Sidekiq queue See github.com/mperham/sidekiq/wiki/Monitoring#monitoring-queue-latency

queue - The name of the Sidekiq queue to check threshold - An Integer to compare the queue’s latency against to consider

it backed up


16
17
18
19
20
# File 'lib/ok_computer/built_in_checks/sidekiq_latency_check.rb', line 16

def initialize(queue, threshold = 30)
  self.queue = queue
  self.name = "Sidekiq queue '#{queue}' latency"
  self.threshold = Integer(threshold)
end

Instance Attribute Details

#queueObject

Returns the value of attribute queue.



8
9
10
# File 'lib/ok_computer/built_in_checks/sidekiq_latency_check.rb', line 8

def queue
  @queue
end

Instance Method Details

#sizeObject

Public: The latency of the check’s queue (in seconds)



23
24
25
# File 'lib/ok_computer/built_in_checks/sidekiq_latency_check.rb', line 23

def size
  Sidekiq::Queue.new(queue).latency
end