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
end
def self.pipeline_creation_step_duration_histogram(step)
name = "#{step}_duration_seconds".to_sym
description = step.gsub('gitlab_ci_', '').tr('_', ' ')
comment = "Duration of the #{description}"
labels = {}
name = :gitlab_ci_pipeline_creation_step_duration_seconds
comment = 'Duration of each pipeline creation step'
labels = { step: step.remove('gitlab_ci_') }
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)
......
......@@ -8,8 +8,8 @@ RSpec.describe Gitlab::Ci::Pipeline::Chain::Sequence do
let(:pipeline) { build_stubbed(:ci_pipeline) }
let(:command) { Gitlab::Ci::Pipeline::Chain::Command.new(project: project) }
let(:first_step) { spy('first step') }
let(:second_step) { spy('second step') }
let(:first_step) { spy('first step', name: 'FirstStep') }
let(:second_step) { spy('second step', name: 'SecondStep') }
let(:sequence) { [first_step, second_step] }
let(:histogram) { spy('prometheus metric') }
......@@ -64,12 +64,12 @@ RSpec.describe Gitlab::Ci::Pipeline::Chain::Sequence do
it 'adds step sequence duration to duration histogram' do
expect(command.metrics)
.to receive(:pipeline_creation_step_duration_histogram)
.with(first_step)
.with('first_step')
.ordered
.and_return(histogram)
expect(command.metrics)
.to receive(:pipeline_creation_step_duration_histogram)
.with(second_step)
.with('second_step')
.ordered
.and_return(histogram)
......
......@@ -9,9 +9,9 @@ RSpec.describe ::Gitlab::Ci::Pipeline::Metrics do
expect(::Gitlab::Metrics).to receive(:histogram)
.with(
:gitlab_ci_pipeline_chain_build_duration_seconds,
'Duration of the pipeline chain build',
{},
:gitlab_ci_pipeline_creation_step_duration_seconds,
'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]
)
......
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