diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2017-12-07 10:59:21 +0000 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2017-12-07 10:59:21 +0000 |
commit | fe62860e05ca6e3ef7125fe92fdf52cd6f7b63df (patch) | |
tree | fcb02f1a0a74f55568d3df3df8b6fe97c7dc1a3d /lib | |
parent | 788f08b70a8b354ec7ed4496915c15dc64c1fa2f (diff) | |
parent | be12f3ed24b7c2d120e249d52179eb09bff7c8aa (diff) | |
download | gitlab-ce-fe62860e05ca6e3ef7125fe92fdf52cd6f7b63df.tar.gz |
Merge branch 'metrics/gb/add-tmp-stage-creation-metrics' into 'master'
Add invalid builds counter metric to stage seeds class
See merge request gitlab-org/gitlab-ce!15764
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/ci/pipeline/chain/create.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/gitlab/ci/pipeline/chain/create.rb b/lib/gitlab/ci/pipeline/chain/create.rb index d5e17a123df..d19a2519803 100644 --- a/lib/gitlab/ci/pipeline/chain/create.rb +++ b/lib/gitlab/ci/pipeline/chain/create.rb @@ -17,11 +17,27 @@ module Gitlab end rescue ActiveRecord::RecordInvalid => e error("Failed to persist the pipeline: #{e}") + ensure + if pipeline.builds.where(stage_id: nil).any? + invalid_builds_counter.increment(node: hostname) + end end def break? !pipeline.persisted? end + + private + + def invalid_builds_counter + @counter ||= Gitlab::Metrics + .counter(:gitlab_ci_invalid_builds_total, + 'Invalid builds without stage assigned counter') + end + + def hostname + @hostname ||= Socket.gethostname + end end end end |