ebf98f27c4
Enables frozen string for the following: * lib/gitlab/fogbugz_import/**/*.rb * lib/gitlab/gfm/**/*.rb * lib/gitlab/git/**/*.rb * lib/gitlab/gitaly_client/**/*.rb * lib/gitlab/gitlab_import/**/*.rb * lib/gitlab/google_code_import/**/*.rb * lib/gitlab/gpg/**/*.rb * lib/gitlab/grape_logging/**/*.rb * lib/gitlab/graphql/**/*.rb * lib/gitlab/graphs/**/*.rb * lib/gitlab/hashed_storage/**/*.rb * lib/gitlab/health_checks/**/*.rb Partially address gitlab-org/gitlab-ce#47424.
44 lines
1.2 KiB
Ruby
44 lines
1.2 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
module Gitlab
|
|
module HealthChecks
|
|
module SimpleAbstractCheck
|
|
include BaseAbstractCheck
|
|
|
|
def readiness
|
|
check_result = check
|
|
if successful?(check_result)
|
|
HealthChecks::Result.new(true)
|
|
elsif check_result.is_a?(Timeout::Error)
|
|
HealthChecks::Result.new(false, "#{human_name} check timed out")
|
|
else
|
|
HealthChecks::Result.new(false, "unexpected #{human_name} check result: #{check_result}")
|
|
end
|
|
end
|
|
|
|
def metrics
|
|
result, elapsed = with_timing(&method(:check))
|
|
Rails.logger.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
|
|
|
|
private
|
|
|
|
def metric_prefix
|
|
raise NotImplementedError
|
|
end
|
|
|
|
def successful?(result)
|
|
raise NotImplementedError
|
|
end
|
|
|
|
def check
|
|
raise NotImplementedError
|
|
end
|
|
end
|
|
end
|
|
end
|