Commit 50f16f19 authored by Sean McGivern's avatar Sean McGivern

Merge branch 'feature/gb/shared-runners-queue-retrieval-histogram' into 'master'

Add runner type label to queue retrieval duration histogram

See merge request gitlab-org/gitlab!57815
parents ab996b3e 9d8aea25
...@@ -24,7 +24,7 @@ module Ci ...@@ -24,7 +24,7 @@ module Ci
def execute(params = {}) def execute(params = {})
@metrics.increment_queue_operation(:queue_attempt) @metrics.increment_queue_operation(:queue_attempt)
@metrics.observe_queue_time(:process) do @metrics.observe_queue_time(:process, @runner.runner_type) do
process_queue(params) process_queue(params)
end end
end end
...@@ -128,7 +128,7 @@ module Ci ...@@ -128,7 +128,7 @@ module Ci
# rubocop: enable CodeReuse/ActiveRecord # rubocop: enable CodeReuse/ActiveRecord
def retrieve_queue(queue_query_proc) def retrieve_queue(queue_query_proc)
@metrics.observe_queue_time(:retrieve) do @metrics.observe_queue_time(:retrieve, @runner.runner_type) do
queue_query_proc.call queue_query_proc.call
end end
end end
......
...@@ -100,7 +100,7 @@ module Gitlab ...@@ -100,7 +100,7 @@ module Gitlab
self.class.queue_size_total.observe({ runner_type: runner_type }, size_proc.call.to_f) self.class.queue_size_total.observe({ runner_type: runner_type }, size_proc.call.to_f)
end end
def observe_queue_time(metric) def observe_queue_time(metric, runner_type)
start_time = ::Gitlab::Metrics::System.monotonic_time start_time = ::Gitlab::Metrics::System.monotonic_time
result = yield result = yield
...@@ -111,9 +111,9 @@ module Gitlab ...@@ -111,9 +111,9 @@ module Gitlab
case metric case metric
when :process when :process
self.class.queue_iteration_duration_seconds.observe({}, seconds.to_f) self.class.queue_iteration_duration_seconds.observe({ runner_type: runner_type }, seconds.to_f)
when :retrieve when :retrieve
self.class.queue_retrieval_duration_seconds.observe({}, seconds.to_f) self.class.queue_retrieval_duration_seconds.observe({ runner_type: runner_type }, seconds.to_f)
else else
raise ArgumentError unless Rails.env.production? raise ArgumentError unless Rails.env.production?
end end
......
...@@ -615,13 +615,25 @@ module Ci ...@@ -615,13 +615,25 @@ module Ci
create(:ci_build, pipeline: pipeline, tag_list: %w[non-matching]) create(:ci_build, pipeline: pipeline, tag_list: %w[non-matching])
end end
it "observes queue size of only matching jobs" do it 'observes queue size of only matching jobs' do
# pending_job + 2 x matching ones # pending_job + 2 x matching ones
expect(Gitlab::Ci::Queue::Metrics.queue_size_total).to receive(:observe) expect(Gitlab::Ci::Queue::Metrics.queue_size_total).to receive(:observe)
.with({ runner_type: specific_runner.runner_type }, 3) .with({ runner_type: specific_runner.runner_type }, 3)
expect(execute(specific_runner)).to eq(pending_job) expect(execute(specific_runner)).to eq(pending_job)
end end
it 'observes queue processing time by the runner type' do
expect(Gitlab::Ci::Queue::Metrics.queue_iteration_duration_seconds)
.to receive(:observe)
.with({ runner_type: specific_runner.runner_type }, anything)
expect(Gitlab::Ci::Queue::Metrics.queue_retrieval_duration_seconds)
.to receive(:observe)
.with({ runner_type: specific_runner.runner_type }, anything)
expect(execute(specific_runner)).to eq(pending_job)
end
end end
context 'when ci_register_job_temporary_lock is enabled' do context 'when ci_register_job_temporary_lock is enabled' do
......
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