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
This commit is contained in:
Kamil Trzciński 2017-12-07 10:59:21 +00:00
commit fe62860e05
1 changed files with 16 additions and 0 deletions

View File

@ -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