Class: Gitlab::HealthChecks::GitalyCheck

Inherits:
Object
  • Object
show all
Extended by:
BaseAbstractCheck
Defined in:
lib/gitlab/health_checks/gitaly_check.rb

Constant Summary collapse

METRIC_PREFIX =
'gitaly_health_check'

Class Method Summary collapse

Methods included from BaseAbstractCheck

available?, human_name, metrics, name, readiness

Class Method Details

.check(storage_name) ⇒ Object


29
30
31
32
33
34
35
36
37
38
39
# File 'lib/gitlab/health_checks/gitaly_check.rb', line 29

def check(storage_name)
  serv = Gitlab::GitalyClient::HealthCheckService.new(storage_name)
  result = serv.check

  HealthChecks::Result.new(
    name,
    result[:success],
    result[:message],
    shard: storage_name
  )
end

.metricsObject


17
18
19
20
21
22
23
24
25
26
27
# File 'lib/gitlab/health_checks/gitaly_check.rb', line 17

def metrics
  Gitaly::Server.all.flat_map do |server|
    result, elapsed = with_timing { server.read_writeable? }
    labels = { shard: server.storage }

    [
      metric("#{metric_prefix}_success", result ? 1 : 0, **labels),
      metric("#{metric_prefix}_latency_seconds", elapsed, **labels)
    ]
  end
end

.readinessObject


11
12
13
14
15
# File 'lib/gitlab/health_checks/gitaly_check.rb', line 11

def readiness
  repository_storages.map do |storage_name|
    check(storage_name)
  end
end