Commit 5cc1340c authored by Dmytro Zaporozhets's avatar Dmytro Zaporozhets

Merge branch 'add-auto-devops-pipeline-metrics' into 'master'

Add initial Auto DevOps pipeline metrics

See merge request gitlab-org/gitlab!22766
parents 75520bd3 a204da04
......@@ -197,6 +197,10 @@ module Ci
AutoMergeProcessWorker.perform_async(merge_request.id)
end
if pipeline.auto_devops_source?
self.class.auto_devops_pipelines_completed_total.increment(status: pipeline.status)
end
end
end
......@@ -330,6 +334,10 @@ module Ci
::Ci::Pipeline::AVAILABLE_STATUSES - %w[created waiting_for_resource preparing pending]
end
def self.auto_devops_pipelines_completed_total
@auto_devops_pipelines_completed_total ||= Gitlab::Metrics.counter(:auto_devops_pipelines_completed_total, 'Number of completed auto devops pipelines')
end
def stages_count
statuses.select(:stage).distinct.count
end
......
......@@ -1183,6 +1183,38 @@ describe Ci::Pipeline, :mailer do
end
end
describe 'auto devops pipeline metrics' do
using RSpec::Parameterized::TableSyntax
let(:pipeline) { create(:ci_empty_pipeline, config_source: config_source) }
let(:config_source) { :auto_devops_source }
where(:action, :status) do
:succeed | 'success'
:drop | 'failed'
:skip | 'skipped'
:cancel | 'canceled'
end
with_them do
context "when pipeline receives action '#{params[:action]}'" do
subject { pipeline.public_send(action) }
it { expect { subject }.to change { auto_devops_pipelines_completed_total(status) }.by(1) }
context 'when not auto_devops_source?' do
let(:config_source) { :repository_source }
it { expect { subject }.not_to change { auto_devops_pipelines_completed_total(status) } }
end
end
end
def auto_devops_pipelines_completed_total(status)
Gitlab::Metrics.counter(:auto_devops_pipelines_completed_total, 'Number of completed auto devops pipelines').get(status: status)
end
end
def create_build(name, *traits, queued_at: current, started_from: 0, **opts)
create(:ci_build, *traits,
name: name,
......
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