Sha256: f6c7814bdf3522084f9f58fe627b149b460e593e7ceff8b9f6caa1de3885eb2a
Contents?: true
Size: 1.59 KB
Versions: 29
Compression:
Stored size: 1.59 KB
Contents
module GovukHealthcheck class SidekiqQueueCheck def status queues.each do |name, value| if value >= critical_threshold(queue: name) return :critical elsif value >= warning_threshold(queue: name) return :warning end end :ok end def message messages = queues.map do |name, value| critical = critical_threshold(queue: name) warning = warning_threshold(queue: name) if value >= critical "#{name} (#{value}) is above the critical threshold (#{critical})" elsif value >= warning "#{name} (#{value}) is above the warning threshold (#{warning})" end end messages = messages.compact if messages.empty? "all queues are below the critical and warning thresholds" else messages.join("\n") end end def details { queues: queues.each_with_object({}) do |(name, value), hash| hash[name] = { value: value, thresholds: { critical: critical_threshold(queue: name), warning: warning_threshold(queue: name), }.select { |_, val| !(val.to_f.infinite? || val.to_f.nan?) }, } end, } end def queues raise "This method must be overriden to be a hash of queue names and data." end def critical_threshold(queue:) raise "This method must be overriden to be the critical threshold." end def warning_threshold(queue:) raise "This method must be overriden to be the warning threshold." end end end
Version data entries
29 entries across 29 versions & 1 rubygems