Module: Gitlab::HealthChecks::SimpleAbstractCheck

Includes:
BaseAbstractCheck
Included in:
DbCheck, MasterCheck, PumaCheck, Redis::CacheCheck, Redis::QueuesCheck, Redis::RedisCheck, Redis::SharedStateCheck, UnicornCheck
Defined in:
lib/gitlab/health_checks/simple_abstract_check.rb

Instance Method Summary collapse

Methods included from BaseAbstractCheck

#human_name, #name

Instance Method Details

#metricsObject


23
24
25
26
27
28
29
30
31
32
33
# File 'lib/gitlab/health_checks/simple_abstract_check.rb', line 23

def metrics
  result, elapsed = with_timing(&method(:check))
  return if result.nil?

  Gitlab::AppLogger.error("#{human_name} check returned unexpected result #{result}") unless successful?(result)
  [
    metric("#{metric_prefix}_timeout", result.is_a?(Timeout::Error) ? 1 : 0),
    metric("#{metric_prefix}_success", successful?(result) ? 1 : 0),
    metric("#{metric_prefix}_latency_seconds", elapsed)
  ]
end

#readinessObject


8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/gitlab/health_checks/simple_abstract_check.rb', line 8

def readiness
  check_result = check
  return if check_result.nil?

  if successful?(check_result)
    HealthChecks::Result.new(name, true)
  elsif check_result.is_a?(Timeout::Error)
    HealthChecks::Result.new(name, false, "#{human_name} check timed out")
  else
    HealthChecks::Result.new(name, false, "unexpected #{human_name} check result: #{check_result}")
  end
rescue => e
  HealthChecks::Result.new(name, false, "unexpected #{human_name} check result: #{e}")
end