summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-12-06 15:11:38 +0100
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-12-06 15:12:04 +0100
commit382a1ef45360b538a80fd5d34cde71f53522dc2a (patch)
tree36ed232de71c79edc003152706f0780fee642169
parent0131c97c611e3327d819f61a09724e21708e0259 (diff)
downloadgitlab-ce-382a1ef45360b538a80fd5d34cde71f53522dc2a.tar.gz
Add invalid builds counter metric to stage seeds class
-rw-r--r--lib/gitlab/ci/stage/seed.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/gitlab/ci/stage/seed.rb b/lib/gitlab/ci/stage/seed.rb
index bc97aa63b02..6a3b2f6cc4a 100644
--- a/lib/gitlab/ci/stage/seed.rb
+++ b/lib/gitlab/ci/stage/seed.rb
@@ -39,6 +39,10 @@ module Gitlab
pipeline.stages.create!(stage).tap do |stage|
builds_attributes = builds.map do |attributes|
attributes.merge(stage_id: stage.id)
+
+ if attributes.fetch(:stage_id).nil?
+ invalid_builds_counter.increment(node: hostname)
+ end
end
pipeline.builds.create!(builds_attributes).each do |build|
@@ -52,6 +56,15 @@ module Gitlab
def protected_ref?
@protected_ref ||= project.protected_for?(pipeline.ref)
end
+
+ def invalid_builds_counter
+ @counter ||= Gitlab::Metrics.counter(:invalid_builds_counter,
+ 'Builds without stage assigned counter')
+ end
+
+ def hostname
+ @hostname ||= Socket.gethostname
+ end
end
end
end