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

predefined_dashboard_service.rb « dashboard « metrics « services « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f454df63773d8633625f3884905cc0306e761655 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# frozen_string_literal: true

module Metrics
  module Dashboard
    class PredefinedDashboardService < ::Metrics::Dashboard::BaseService
      # These constants should be overridden in the inheriting class. For Ex:
      # DASHBOARD_PATH = 'config/prometheus/common_metrics.yml'
      # DASHBOARD_NAME = 'Default'
      DASHBOARD_PATH = nil
      DASHBOARD_NAME = nil

      SEQUENCE = [
        STAGES::EndpointInserter,
        STAGES::PanelIdsInserter,
        STAGES::Sorter
      ].freeze

      class << self
        def valid_params?(params)
          matching_dashboard?(params[:dashboard_path])
        end

        def matching_dashboard?(filepath)
          filepath == self::DASHBOARD_PATH
        end
      end

      private

      def cache_key
        "metrics_dashboard_#{dashboard_path}"
      end

      def dashboard_path
        self.class::DASHBOARD_PATH
      end

      # Returns the base metrics shipped with every GitLab service.
      def get_raw_dashboard
        yml = File.read(Rails.root.join(dashboard_path))

        YAML.safe_load(yml)
      end

      def sequence
        self.class::SEQUENCE
      end
    end
  end
end