Class: Gitlab::Metrics::Dashboard::Stages::CustomMetricsInserter

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

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

Inserts project-specific metrics into the dashboard config. If there are no project-specific metrics, this will have no effect.


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

def transform!
  custom_metrics = PrometheusMetricsFinder.new(project: project, ordered: true).execute
  custom_metrics = Gitlab::Utils.stable_sort_by(custom_metrics) { |metric| -metric.priority }

  custom_metrics.each do |project_metric|
    group = find_or_create_panel_group(dashboard[:panel_groups], project_metric)
    panel = find_or_create_panel(group[:panels], project_metric)
    find_or_create_metric(panel[:metrics], project_metric)
  end
end