Commit 3bace63a authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch 'limited-capacity-worker-report-running-metrics-on-start' into 'master'

Report running jobs metrics when the job starts

See merge request gitlab-org/gitlab!46155
parents ef2ff241 b8f4071b
......@@ -67,6 +67,7 @@ module LimitedCapacity
return unless has_capacity?
job_tracker.register(jid)
report_running_jobs_metrics
perform_work(*args)
rescue => exception
raise
......@@ -108,11 +109,15 @@ module LimitedCapacity
end
def report_prometheus_metrics(*args)
running_jobs_gauge.set(prometheus_labels, running_jobs_count)
report_running_jobs_metrics
remaining_work_gauge.set(prometheus_labels, remaining_work_count(*args))
max_running_jobs_gauge.set(prometheus_labels, max_running_jobs)
end
def report_running_jobs_metrics
running_jobs_gauge.set(prometheus_labels, running_jobs_count)
end
def required_jobs_count(*args)
[
remaining_work_count(*args),
......
......@@ -121,7 +121,8 @@ RSpec.describe LimitedCapacity::Worker, :clean_gitlab_redis_queues, :aggregate_f
it 'reports prometheus metrics' do
allow(worker).to receive(:perform_work)
expect(worker).to receive(:report_prometheus_metrics)
expect(worker).to receive(:report_prometheus_metrics).once.and_call_original
expect(worker).to receive(:report_running_jobs_metrics).twice.and_call_original
perform
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment