Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-06-18 14:18:50 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-06-18 14:18:50 +0300
commit8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781 (patch)
treea77e7fe7a93de11213032ed4ab1f33a3db51b738 /lib/gitlab/prometheus
parent00b35af3db1abfe813a778f643dad221aad51fca (diff)
Add latest changes from gitlab-org/gitlab@13-1-stable-ee
Diffstat (limited to 'lib/gitlab/prometheus')
-rw-r--r--lib/gitlab/prometheus/query_variables.rb14
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/gitlab/prometheus/query_variables.rb b/lib/gitlab/prometheus/query_variables.rb
index 4d48c4a3af7..5b688f83545 100644
--- a/lib/gitlab/prometheus/query_variables.rb
+++ b/lib/gitlab/prometheus/query_variables.rb
@@ -3,8 +3,10 @@
module Gitlab
module Prometheus
module QueryVariables
- def self.call(environment)
+ # start_time and end_time should be Time objects.
+ def self.call(environment, start_time: nil, end_time: nil)
{
+ __range: range(start_time, end_time),
ci_environment_slug: environment.slug,
kube_namespace: environment.deployment_namespace || '',
environment_filter: %{container_name!="POD",environment="#{environment.slug}"},
@@ -14,6 +16,16 @@ module Gitlab
ci_environment_name: environment.name
}
end
+
+ private
+
+ def self.range(start_time, end_time)
+ if start_time && end_time
+ range_seconds = (end_time - start_time).to_i
+ "#{range_seconds}s"
+ end
+ end
+ private_class_method :range
end
end
end