2cd7b78391
Correct the ordering of metrics on performance dashboard. Before common metrics were moved into the DB, metric groups were ordered by the priority defined in the common_metrics.yml file. This commit adds a priority to each metric group in the PrometheusMetric model. It also combines title, priority and required_metrics into one frozen GROUP_DETAILS hash so that the code is clearer. This can be done since there is a fixed set of groups which are not configurable.
30 lines
687 B
Ruby
30 lines
687 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Gitlab
|
|
module Prometheus
|
|
class MetricGroup
|
|
include ActiveModel::Model
|
|
|
|
attr_accessor :name, :priority, :metrics
|
|
|
|
validates :name, :priority, :metrics, presence: true
|
|
|
|
def self.common_metrics
|
|
all_groups = ::PrometheusMetric.common.group_by(&:group_title).map do |name, metrics|
|
|
MetricGroup.new(
|
|
name: name,
|
|
priority: metrics.map(&:priority).max,
|
|
metrics: metrics.map(&:to_query_metric)
|
|
)
|
|
end
|
|
|
|
all_groups.sort_by(&:priority).reverse
|
|
end
|
|
|
|
# EE only
|
|
def self.for_project(_)
|
|
common_metrics
|
|
end
|
|
end
|
|
end
|
|
end
|