Class: Gitlab::Memory::Watchdog::Monitor::HeapFragmentation

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

Overview

A monitor that observes Ruby heap fragmentation. See Gitlab::Metrics::Memory for how heap fragmentation is defined.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(max_heap_fragmentation:) ⇒ HeapFragmentation

max_heap_fragmentation:

The degree to which the Ruby heap is allowed to be fragmented. Range [0,1].


14
15
16
17
# File 'lib/gitlab/memory/watchdog/monitor/heap_fragmentation.rb', line 14

def initialize(max_heap_fragmentation:)
  @max_heap_fragmentation = max_heap_fragmentation
  init_frag_limit_metrics
end

Instance Attribute Details

#max_heap_fragmentationObject (readonly)

Returns the value of attribute max_heap_fragmentation.



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

def max_heap_fragmentation
  @max_heap_fragmentation
end

Instance Method Details

#callObject



19
20
21
22
23
24
25
# File 'lib/gitlab/memory/watchdog/monitor/heap_fragmentation.rb', line 19

def call
  heap_fragmentation = Gitlab::Metrics::Memory.gc_heap_fragmentation

  return { threshold_violated: false, payload: {} } if heap_fragmentation <= max_heap_fragmentation

  { threshold_violated: true, payload: payload(heap_fragmentation) }
end