Welcome to mirror list, hosted at ThFree Co, Russian Federation.

health_status.rb « database « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 69bb8a70afdff9247176e537018c9087fdd5b496 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# frozen_string_literal: true

module Gitlab
  module Database
    module HealthStatus
      DEFAULT_INIDICATORS = [
        Indicators::AutovacuumActiveOnTable,
        Indicators::WriteAheadLog,
        Indicators::PatroniApdex
      ].freeze

      class << self
        def evaluate(context, indicators = DEFAULT_INIDICATORS)
          indicators.map do |indicator|
            signal = begin
              indicator.new(context).evaluate
            rescue StandardError => e
              Gitlab::ErrorTracking.track_exception(e, **context.status_checker_info)

              Signals::Unknown.new(indicator, reason: "unexpected error: #{e.message} (#{e.class})")
            end

            log_signal(signal, context) if signal.log_info?

            signal
          end
        end

        def log_signal(signal, context)
          Gitlab::Database::HealthStatus::Logger.info(**context.status_checker_info.merge(
            health_status_indicator: signal.indicator_class.to_s,
            indicator_signal: signal.short_name,
            signal_reason: signal.reason,
            message: "#{context.status_checker} signaled: #{signal}"
          ))
        end
      end
    end
  end
end