Class: Gitlab::Metrics::Dashboard::Stages::CustomDashboardMetricsInserter

Inherits:
BaseStage
  • Object
show all
Defined in:
lib/gitlab/metrics/dashboard/stages/custom_dashboard_metrics_inserter.rb

Overview

Acts on metrics which have been ingested from source controlled dashboards

Constant Summary

Constants included from Defaults

Defaults::DEFAULT_PANEL_TYPE

Instance Attribute Summary

Attributes inherited from BaseStage

#dashboard, #params, #project

Instance Method Summary collapse

Methods inherited from BaseStage

#initialize

Constructor Details

This class inherits a constructor from Gitlab::Metrics::Dashboard::Stages::BaseStage

Instance Method Details

#transform!Object

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.


12
13
14
15
16
17
18
19
# File 'lib/gitlab/metrics/dashboard/stages/custom_dashboard_metrics_inserter.rb', line 12

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