Skip to content

Extract watchdog event reporter

Nikola Milojevic requested to merge extract_watchdog_violation_reporter into master

What does this MR do and why?

It extracts metric and logs to eventreporter.

Event reporter is configurable, and it allows us to use separate event reporter for sidekiq in the future. As the next step, we could introduce SidekiqEventReporter which would use composition over inheritance, and it will just log and increase additional metrics specific to Sidekiq.

        def configure_for_sidekiq
            ->(config) do
              config.handler = Gitlab::Memory::Watchdog::TermProcessHandler.new
              config.write_heap_dumps = write_heap_dumps?
              config.sleep_time_seconds = sidekiq_sleep_time
              config.monitors(&configure_monitors_for_sidekiq)
              config.event_reporter = EventReporter.new(Sidekiq.logger)
            end
          end

Events

          event_reporter.started
          event_reporter.stopped
          event_reporter.threshold_violated(monitor_name: monitor_name)
          event_reporter.strikes_exceeded(
            monitor_name: monitor_name,
            monitor_payload: monitor_payload
          )

Screenshots or screen recordings

Screenshots are required for UI changes and are strongly recommended for all other merge requests.

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to: #383853 (closed)

Edited by Nikola Milojevic

Merge request reports