debian-mirror-gitlab/lib/gitlab/prometheus/metric_group.rb

31 lines
687 B
Ruby
Raw Normal View History

2019-02-15 15:39:39 +05:30
# frozen_string_literal: true
2017-09-10 17:25:29 +05:30
module Gitlab
module Prometheus
class MetricGroup
include ActiveModel::Model
attr_accessor :name, :priority, :metrics
2018-11-20 20:47:30 +05:30
2017-09-10 17:25:29 +05:30
validates :name, :priority, :metrics, presence: true
2018-03-27 19:54:05 +05:30
def self.common_metrics
2019-02-15 15:39:39 +05:30
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)
)
2018-11-20 20:47:30 +05:30
end
2019-02-15 15:39:39 +05:30
all_groups.sort_by(&:priority).reverse
2017-09-10 17:25:29 +05:30
end
2018-03-27 19:54:05 +05:30
# EE only
def self.for_project(_)
common_metrics
end
2017-09-10 17:25:29 +05:30
end
end
end