Class: Gitlab::Memory::Watchdog::EventReporter

Inherits:
Object
  • Object
show all
Includes:
Utils::StrongMemoize
Defined in:
lib/gitlab/memory/watchdog/event_reporter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(logger: Gitlab::AppLogger) ⇒ EventReporter

Returns a new instance of EventReporter.



11
12
13
14
# File 'lib/gitlab/memory/watchdog/event_reporter.rb', line 11

def initialize(logger: Gitlab::AppLogger)
  @logger = logger
  init_prometheus_metrics
end

Instance Attribute Details

#loggerObject (readonly)

Returns the value of attribute logger.



9
10
11
# File 'lib/gitlab/memory/watchdog/event_reporter.rb', line 9

def logger
  @logger
end

Instance Method Details

#started(labels = {}) ⇒ Object



16
17
18
# File 'lib/gitlab/memory/watchdog/event_reporter.rb', line 16

def started(labels = {})
  logger.info(message: 'started', **log_labels(labels))
end

#stopped(labels = {}) ⇒ Object



20
21
22
# File 'lib/gitlab/memory/watchdog/event_reporter.rb', line 20

def stopped(labels = {})
  logger.info(message: 'stopped', **log_labels(labels))
end

#strikes_exceeded(monitor_name, labels = {}) ⇒ Object



28
29
30
31
32
# File 'lib/gitlab/memory/watchdog/event_reporter.rb', line 28

def strikes_exceeded(monitor_name, labels = {})
  logger.warn(log_labels(labels))

  @counter_violations_handled.increment(reason: monitor_name)
end

#threshold_violated(monitor_name) ⇒ Object



24
25
26
# File 'lib/gitlab/memory/watchdog/event_reporter.rb', line 24

def threshold_violated(monitor_name)
  @counter_violations.increment(reason: monitor_name)
end