Commit 34810d37 authored by Avielle Wolfe's avatar Avielle Wolfe

Track duration of each step in one histogram

Tracking them all in separate histograms would make the PE dashboard
very large and slightly messy
parent 87d830f3
...@@ -14,10 +14,9 @@ module Gitlab ...@@ -14,10 +14,9 @@ module Gitlab
end end
def self.pipeline_creation_step_duration_histogram(step) def self.pipeline_creation_step_duration_histogram(step)
name = "#{step}_duration_seconds".to_sym name = :gitlab_ci_pipeline_creation_step_duration_seconds
description = step.gsub('gitlab_ci_', '').tr('_', ' ') comment = 'Duration of each pipeline creation step'
comment = "Duration of the #{description}" labels = { step: step.remove('gitlab_ci_') }
labels = {}
buckets = [0.01, 0.05, 0.1, 0.5, 1.0, 2.0, 5.0, 10.0, 15.0, 20.0, 50.0, 240.0] buckets = [0.01, 0.05, 0.1, 0.5, 1.0, 2.0, 5.0, 10.0, 15.0, 20.0, 50.0, 240.0]
::Gitlab::Metrics.histogram(name, comment, labels, buckets) ::Gitlab::Metrics.histogram(name, comment, labels, buckets)
......
...@@ -8,8 +8,8 @@ RSpec.describe Gitlab::Ci::Pipeline::Chain::Sequence do ...@@ -8,8 +8,8 @@ RSpec.describe Gitlab::Ci::Pipeline::Chain::Sequence do
let(:pipeline) { build_stubbed(:ci_pipeline) } let(:pipeline) { build_stubbed(:ci_pipeline) }
let(:command) { Gitlab::Ci::Pipeline::Chain::Command.new(project: project) } let(:command) { Gitlab::Ci::Pipeline::Chain::Command.new(project: project) }
let(:first_step) { spy('first step') } let(:first_step) { spy('first step', name: 'FirstStep') }
let(:second_step) { spy('second step') } let(:second_step) { spy('second step', name: 'SecondStep') }
let(:sequence) { [first_step, second_step] } let(:sequence) { [first_step, second_step] }
let(:histogram) { spy('prometheus metric') } let(:histogram) { spy('prometheus metric') }
...@@ -64,12 +64,12 @@ RSpec.describe Gitlab::Ci::Pipeline::Chain::Sequence do ...@@ -64,12 +64,12 @@ RSpec.describe Gitlab::Ci::Pipeline::Chain::Sequence do
it 'adds step sequence duration to duration histogram' do it 'adds step sequence duration to duration histogram' do
expect(command.metrics) expect(command.metrics)
.to receive(:pipeline_creation_step_duration_histogram) .to receive(:pipeline_creation_step_duration_histogram)
.with(first_step) .with('first_step')
.ordered .ordered
.and_return(histogram) .and_return(histogram)
expect(command.metrics) expect(command.metrics)
.to receive(:pipeline_creation_step_duration_histogram) .to receive(:pipeline_creation_step_duration_histogram)
.with(second_step) .with('second_step')
.ordered .ordered
.and_return(histogram) .and_return(histogram)
......
...@@ -9,9 +9,9 @@ RSpec.describe ::Gitlab::Ci::Pipeline::Metrics do ...@@ -9,9 +9,9 @@ RSpec.describe ::Gitlab::Ci::Pipeline::Metrics do
expect(::Gitlab::Metrics).to receive(:histogram) expect(::Gitlab::Metrics).to receive(:histogram)
.with( .with(
:gitlab_ci_pipeline_chain_build_duration_seconds, :gitlab_ci_pipeline_creation_step_duration_seconds,
'Duration of the pipeline chain build', 'Duration of each pipeline creation step',
{}, { step: 'pipeline_chain_build' },
[0.01, 0.05, 0.1, 0.5, 1.0, 2.0, 5.0, 10.0, 15.0, 20.0, 50.0, 240.0] [0.01, 0.05, 0.1, 0.5, 1.0, 2.0, 5.0, 10.0, 15.0, 20.0, 50.0, 240.0]
) )
......
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