diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-20 12:07:40 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-20 12:07:40 +0000 |
commit | f864f8a7aafa45b0e4c04e4312f89da4b1227c0f (patch) | |
tree | e559b53ae6a7594f28409bab9d38325200b38495 /app/models | |
parent | 898e2cc1dfa88b4ac39cb4b35011f61b37f57b51 (diff) | |
download | gitlab-ce-f864f8a7aafa45b0e4c04e4312f89da4b1227c0f.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/deployment_metrics.rb | 10 | ||||
-rw-r--r-- | app/models/environment.rb | 8 |
2 files changed, 13 insertions, 5 deletions
diff --git a/app/models/deployment_metrics.rb b/app/models/deployment_metrics.rb index 2056c8bc59c..20f0ec3e9b6 100644 --- a/app/models/deployment_metrics.rb +++ b/app/models/deployment_metrics.rb @@ -13,18 +13,18 @@ class DeploymentMetrics end def has_metrics? - deployment.success? && prometheus_adapter&.can_query? + deployment.success? && prometheus_adapter&.configured? end def metrics - return {} unless has_metrics? + return {} unless has_metrics_and_can_query? metrics = prometheus_adapter.query(:deployment, deployment) metrics&.merge(deployment_time: deployment.finished_at.to_i) || {} end def additional_metrics - return {} unless has_metrics? + return {} unless has_metrics_and_can_query? metrics = prometheus_adapter.query(:additional_metrics_deployment, deployment) metrics&.merge(deployment_time: deployment.finished_at.to_i) || {} @@ -47,4 +47,8 @@ class DeploymentMetrics def cluster_prometheus cluster.application_prometheus if cluster&.application_prometheus_available? end + + def has_metrics_and_can_query? + has_metrics? && prometheus_adapter.can_query? + end end diff --git a/app/models/environment.rb b/app/models/environment.rb index 82bf0f9a615..84a72fee77b 100644 --- a/app/models/environment.rb +++ b/app/models/environment.rb @@ -208,7 +208,7 @@ class Environment < ApplicationRecord end def metrics - prometheus_adapter.query(:environment, self) if has_metrics? && prometheus_adapter.can_query? + prometheus_adapter.query(:environment, self) if has_metrics_and_can_query? end def prometheus_status @@ -216,7 +216,7 @@ class Environment < ApplicationRecord end def additional_metrics(*args) - return unless has_metrics? + return unless has_metrics_and_can_query? prometheus_adapter.query(:additional_metrics_environment, self, *args.map(&:to_f)) end @@ -285,6 +285,10 @@ class Environment < ApplicationRecord private + def has_metrics_and_can_query? + has_metrics? && prometheus_adapter.can_query? + end + def generate_slug self.slug = Gitlab::Slug::Environment.new(name).generate end |