diff options
author | Z.J. van de Weg <git@zjvandeweg.nl> | 2017-07-24 12:44:33 +0200 |
---|---|---|
committer | Z.J. van de Weg <git@zjvandeweg.nl> | 2017-07-31 11:51:28 +0200 |
commit | 5f86347ee614445d23ec9b21cf77fcbcf790756c (patch) | |
tree | 7e5024748953fa9b77e7fc492afb9ed7d77b6d1f | |
parent | 202806c029802dee6924925313d75d476192ea59 (diff) | |
download | gitlab-ce-5f86347ee614445d23ec9b21cf77fcbcf790756c.tar.gz |
Add two more metrics for CI/CDzj-add-ci-metrics
As its hard right now to determine what is a good metric and whats not,
these two are not listed in the docs, nor will they get a CHANGELOG
entry.
-rw-r--r-- | app/services/ci/register_job_service.rb | 24 | ||||
-rw-r--r-- | app/services/projects/update_pages_service.rb | 18 |
2 files changed, 42 insertions, 0 deletions
diff --git a/app/services/ci/register_job_service.rb b/app/services/ci/register_job_service.rb index b951e8d0c9f..fc87bd6a659 100644 --- a/app/services/ci/register_job_service.rb +++ b/app/services/ci/register_job_service.rb @@ -30,6 +30,7 @@ module Ci # with StateMachines::InvalidTransition or StaleObjectError when doing run! or save method. build.runner_id = runner.id build.run! + register_success(build) return Result.new(build, true) rescue StateMachines::InvalidTransition, ActiveRecord::StaleObjectError @@ -46,6 +47,7 @@ module Ci end end + register_failure Result.new(nil, valid) end @@ -81,5 +83,27 @@ module Ci def shared_runner_build_limits_feature_enabled? ENV['DISABLE_SHARED_RUNNER_BUILD_MINUTES_LIMIT'].to_s != 'true' end + + def register_failure + failed_attempt_counter.increase + attempt_counter.increase + end + + def register_success(job) + job_queue_duration_seconds.observe({ shared_runner: @runner.shared? }, Time.now - job.created_at) + attempt_counter.increase + end + + def failed_attempt_counter + @failed_attempt_counter ||= Gitlab::Metrics.counter(:job_register_attempts_failed_total, "Counts the times a runner tries to register a job") + end + + def attempt_counter + @attempt_counter ||= Gitlab::Metrics.counter(:job_register_attempts_total, "Counts the times a runner tries to register a job") + end + + def job_queue_duration_seconds + @job_queue_duration_seconds ||= Gitlab::Metrics.histogram(:job_queue_duration_seconds, 'Request handling execution time') + end end end diff --git a/app/services/projects/update_pages_service.rb b/app/services/projects/update_pages_service.rb index 749a1cc56d8..5038155ca31 100644 --- a/app/services/projects/update_pages_service.rb +++ b/app/services/projects/update_pages_service.rb @@ -33,8 +33,10 @@ module Projects success end rescue => e + register_failure error(e.message) ensure + register_attempt build.erase_artifacts! unless build.has_expiring_artifacts? end @@ -168,5 +170,21 @@ module Projects def sha build.sha end + + def register_attempt + pages_deployments_total_counter.increase + end + + def register_failure + pages_deployments_failed_total_counter.increase + end + + def pages_deployments_total_counter + @pages_deployments_total_counter ||= Gitlab::Metrics.counter(:pages_deployments_total, "Counter of GitLab Pages deployments triggered") + end + + def pages_deployments_failed_total_counter + @pages_deployments_failed_total_counter ||= Gitlab::Metrics.counter(:pages_deployments_failed_total, "Counter of GitLab Pages deployments which failed") + end end end |