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:
authorsyasonik <syasonik@gitlab.com>2019-03-15 14:20:59 +0300
committersyasonik <syasonik@gitlab.com>2019-04-03 12:21:56 +0300
commitab1e1b55a84ffc6b09233a6831be9bdc77c05115 (patch)
treedd59f2fd052b1112429580855536faa59855972a /lib/gitlab/prometheus
parent478077747da82a3dfaafbebc1797b26b965b030f (diff)
Specify time window for additional metrics api
Adds support for start and end parameters in the #additional_metrics endpoint of the EnvironmentsController. start and end are meant to be unix timestamps, per the Prometheus API (as the consumer of this endpoint will eventually be transitioned to a prometheus endpoint). This functionality is behind the :metrics_time_window feature flag for development.
Diffstat (limited to 'lib/gitlab/prometheus')
-rw-r--r--lib/gitlab/prometheus/queries/additional_metrics_environment_query.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/gitlab/prometheus/queries/additional_metrics_environment_query.rb b/lib/gitlab/prometheus/queries/additional_metrics_environment_query.rb
index 34b705138ba..c49877ddf9d 100644
--- a/lib/gitlab/prometheus/queries/additional_metrics_environment_query.rb
+++ b/lib/gitlab/prometheus/queries/additional_metrics_environment_query.rb
@@ -7,12 +7,16 @@ module Gitlab
include QueryAdditionalMetrics
# rubocop: disable CodeReuse/ActiveRecord
- def query(environment_id)
+ def query(environment_id, timeframe_start = 8.hours.ago, timeframe_end = Time.now)
::Environment.find_by(id: environment_id).try do |environment|
query_metrics(
environment.project,
environment,
- common_query_context(environment, timeframe_start: 8.hours.ago.to_f, timeframe_end: Time.now.to_f)
+ common_query_context(
+ environment,
+ timeframe_start: timeframe_start.to_f,
+ timeframe_end: timeframe_end.to_f
+ )
)
end
end