Merge branch 'zj-prom-pipeline-count' into 'master'
Add prometheus metrics on pipeline creation Closes #32624 See merge request !11975
This commit is contained in:
commit
05e88a0d12
|
@ -57,6 +57,8 @@ module Ci
|
|||
|
||||
cancel_pending_pipelines if project.auto_cancel_pending_pipelines?
|
||||
|
||||
pipeline_created_counter.increment(source: source)
|
||||
|
||||
pipeline.tap(&:process!)
|
||||
end
|
||||
|
||||
|
@ -131,5 +133,9 @@ module Ci
|
|||
pipeline.drop if save
|
||||
pipeline
|
||||
end
|
||||
|
||||
def pipeline_created_counter
|
||||
@pipeline_created_counter ||= Gitlab::Metrics.counter(:pipelines_created_count, "Pipelines created count")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
title: Add prometheus metrics on pipeline creation
|
||||
merge_request:
|
||||
author:
|
|
@ -38,6 +38,14 @@ describe Ci::CreatePipelineService, :services do
|
|||
expect(pipeline.builds.first).to be_kind_of(Ci::Build)
|
||||
end
|
||||
|
||||
it 'increments the prometheus counter' do
|
||||
expect(Gitlab::Metrics).to receive(:counter)
|
||||
.with(:pipelines_created_count, "Pipelines created count")
|
||||
.and_call_original
|
||||
|
||||
pipeline
|
||||
end
|
||||
|
||||
context 'when merge requests already exist for this source branch' do
|
||||
it 'updates head pipeline of each merge request' do
|
||||
merge_request_1 = create(:merge_request, source_branch: 'master', target_branch: "branch_1", source_project: project)
|
||||
|
|
Loading…
Reference in New Issue