gitlab-org--gitlab-foss/lib/gitlab/cluster/puma_worker_killer_observer.rb
Jan Provaznik 497acb1670 Add metric for measuring PumaWorkerKiller activity
PumaWorkerKiller is used for periodically checking and killing
workers (the biggest one) if overall memory reaches specified
limit. This metric allows us to watch number of killed workers.
2019-06-10 16:09:40 +00:00

24 lines
554 B
Ruby

# frozen_string_literal: true
module Gitlab
module Cluster
class PumaWorkerKillerObserver
def initialize
@counter = Gitlab::Metrics.counter(:puma_killer_terminations_total, 'Number of workers terminated by PumaWorkerKiller')
end
# returns the Proc to be used as the observer callback block
def callback
method(:log_termination)
end
private
def log_termination(worker)
labels = { worker: "worker_#{worker.index}" }
@counter.increment(labels)
end
end
end
end