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

rss_memory_limit.rb « monitor « watchdog « memory « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3e7de024630cb2a7d12cefa05a49ab0ec9861b9e (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
# frozen_string_literal: true

module Gitlab
  module Memory
    class Watchdog
      module Monitor
        class RssMemoryLimit
          attr_reader :memory_limit

          def initialize(memory_limit:)
            @memory_limit = memory_limit
          end

          def call
            worker_rss = Gitlab::Metrics::System.memory_usage_rss[:total]

            return { threshold_violated: false, payload: {} } if worker_rss <= memory_limit

            { threshold_violated: true, payload: payload(worker_rss, memory_limit) }
          end

          private

          def payload(worker_rss, memory_limit)
            {
              message: 'rss memory limit exceeded',
              memwd_rss_bytes: worker_rss,
              memwd_max_rss_bytes: memory_limit
            }
          end
        end
      end
    end
  end
end