debian-mirror-gitlab/spec/support/helpers/prometheus/metric_builders.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

30 lines
996 B
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2017-09-10 17:25:29 +05:30
module Prometheus
module MetricBuilders
def simple_query(suffix = 'a', **opts)
{ query_range: "query_range_#{suffix}" }.merge(opts)
end
def simple_queries
[simple_query, simple_query('b', label: 'label', unit: 'unit')]
end
def simple_metric(title: 'title', required_metrics: [], queries: [simple_query])
Gitlab::Prometheus::Metric.new(title: title, required_metrics: required_metrics, weight: 1, queries: queries)
end
def simple_metrics(added_metric_name: 'metric_a')
[
2023-06-20 00:43:36 +05:30
simple_metric(required_metrics: %W[#{added_metric_name} metric_b], queries: simple_queries),
2017-09-10 17:25:29 +05:30
simple_metric(required_metrics: [added_metric_name], queries: [simple_query('empty')]),
2023-06-20 00:43:36 +05:30
simple_metric(required_metrics: %w[metric_c])
2017-09-10 17:25:29 +05:30
]
end
def simple_metric_group(name: 'name', metrics: simple_metrics)
Gitlab::Prometheus::MetricGroup.new(name: name, priority: 1, metrics: metrics)
end
end
end