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

custom_dashboard_metrics_inserter.rb « stages « dashboard « metrics « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5ed4466f440e8c1340039238f10702c5f047db7c (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
# frozen_string_literal: true

module Gitlab
  module Metrics
    module Dashboard
      module Stages
        # Acts on metrics which have been ingested from source controlled dashboards
        class CustomDashboardMetricsInserter < BaseStage
          # For each metric in the dashboard config, attempts to
          # find a corresponding database record. If found, includes
          # the record's id in the dashboard config.
          def transform!
            database_metrics = ::PrometheusMetricsFinder.new(common: false, group: :custom, project: project).execute

            for_metrics do |metric|
              metric_record = database_metrics.find { |m| m.identifier == metric[:id] }
              metric[:metric_id] = metric_record.id if metric_record
            end
          end
        end
      end
    end
  end
end