summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorsyasonik <syasonik@gitlab.com>2019-04-16 17:09:10 +0800
committersyasonik <syasonik@gitlab.com>2019-04-24 18:23:03 +0800
commit35c412327cd0a0897d4d81aa80c88782c98fdd89 (patch)
treef593de4da583df8bccb9a9e2153d33f9a6e7c288 /app
parentd307f446d807b03ddc7d55705df5602c275e61fb (diff)
downloadgitlab-ce-35c412327cd0a0897d4d81aa80c88782c98fdd89.tar.gz
Refactor dashboard proccesing into stages
Diffstat (limited to 'app')
-rw-r--r--app/controllers/projects/environments_controller.rb2
-rw-r--r--app/services/metrics_dashboard_service.rb33
2 files changed, 1 insertions, 34 deletions
diff --git a/app/controllers/projects/environments_controller.rb b/app/controllers/projects/environments_controller.rb
index db0253a9183..69ceeab5b99 100644
--- a/app/controllers/projects/environments_controller.rb
+++ b/app/controllers/projects/environments_controller.rb
@@ -162,7 +162,7 @@ class Projects::EnvironmentsController < Projects::ApplicationController
respond_to do |format|
format.json do
- dashboard = MetricsDashboardService.new(@project).get_dashboard
+ dashboard = Gitlab::MetricsDashboard::Service.new(@project).get_dashboard
render json: dashboard, status: :ok
end
diff --git a/app/services/metrics_dashboard_service.rb b/app/services/metrics_dashboard_service.rb
deleted file mode 100644
index b72095744b2..00000000000
--- a/app/services/metrics_dashboard_service.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-# frozen_string_literal: true
-
-# Fetches the metrics dashboard layout and supplemented the output with DB info.
-class MetricsDashboardService
- SYSTEM_DASHBOARD_NAME = 'common_metrics'
- SYSTEM_DASHBOARD_PATH = Rails.root.join('config', 'prometheus', "#{SYSTEM_DASHBOARD_NAME}.yml")
-
- def initialize(project)
- @project = project
- end
-
- # Returns a DB-supplemented json representation of a dashboard config file.
- def get_dashboard
- dashboard = Rails.cache.fetch(cache_key) { system_dashboard }
-
- process_dashboard(dashboard)
- end
-
- private
-
- # Returns the base metrics shipped with every GitLab service.
- def system_dashboard
- YAML.load_file(SYSTEM_DASHBOARD_PATH)
- end
-
- def cache_key
- "metrics_dashboard_#{SYSTEM_DASHBOARD_NAME}"
- end
-
- def process_dashboard(dashboard)
- MetricsDashboardProcessingService.new(dashboard, @project).process
- end
-end