Class: Gitlab::Memory::Watchdog::Monitor::UniqueMemoryGrowth

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/memory/watchdog/monitor/unique_memory_growth.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(max_mem_growth:) ⇒ UniqueMemoryGrowth

Returns a new instance of UniqueMemoryGrowth.



10
11
12
# File 'lib/gitlab/memory/watchdog/monitor/unique_memory_growth.rb', line 10

def initialize(max_mem_growth:)
  @max_mem_growth = max_mem_growth
end

Instance Attribute Details

#max_mem_growthObject (readonly)

Returns the value of attribute max_mem_growth.



8
9
10
# File 'lib/gitlab/memory/watchdog/monitor/unique_memory_growth.rb', line 8

def max_mem_growth
  @max_mem_growth
end

Instance Method Details

#callObject



14
15
16
17
18
19
20
21
22
# File 'lib/gitlab/memory/watchdog/monitor/unique_memory_growth.rb', line 14

def call
  worker_uss = Gitlab::Metrics::System.memory_usage_uss_pss[:uss]
  reference_uss = reference_mem[:uss]
  memory_limit = max_mem_growth * reference_uss

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

  { threshold_violated: true, payload: payload(worker_uss, reference_uss, memory_limit) }
end