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 /app/controllers
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 'app/controllers')
-rw-r--r--app/controllers/projects/environments_controller.rb12
1 files changed, 11 insertions, 1 deletions
diff --git a/app/controllers/projects/environments_controller.rb b/app/controllers/projects/environments_controller.rb
index e9cd475a199..4fa6cd94ae5 100644
--- a/app/controllers/projects/environments_controller.rb
+++ b/app/controllers/projects/environments_controller.rb
@@ -10,6 +10,9 @@ class Projects::EnvironmentsController < Projects::ApplicationController
before_action :environment, only: [:show, :edit, :update, :stop, :terminal, :terminal_websocket_authorize, :metrics]
before_action :verify_api_request!, only: :terminal_websocket_authorize
before_action :expire_etag_cache, only: [:index]
+ before_action only: [:metrics, :additional_metrics] do
+ push_frontend_feature_flag(:metrics_time_window)
+ end
def index
@environments = project.environments
@@ -146,7 +149,7 @@ class Projects::EnvironmentsController < Projects::ApplicationController
def additional_metrics
respond_to do |format|
format.json do
- additional_metrics = environment.additional_metrics || {}
+ additional_metrics = environment.additional_metrics(*metrics_params) || {}
render json: additional_metrics, status: additional_metrics.any? ? :ok : :no_content
end
@@ -186,6 +189,13 @@ class Projects::EnvironmentsController < Projects::ApplicationController
@environment ||= project.environments.find(params[:id])
end
+ def metrics_params
+ return unless Feature.enabled?(:metrics_time_window, project)
+ return unless params[:start].present? || params[:end].present?
+
+ params.require([:start, :end]).values_at(:start, :end)
+ end
+
def search_environment_names
return [] unless params[:query]