Skip to content

Commit f78fd3d

Browse files
committed
Fix Additional metrics filtering
+ remove test button that was leftover after a bad merge
1 parent 6eb96b2 commit f78fd3d

File tree

5 files changed

+9
-6
lines changed

5 files changed

+9
-6
lines changed

app/models/project_services/prometheus_service.rb

+5-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,11 @@ def additional_deployment_metrics(deployment)
7272
end
7373

7474
def matched_metrics
75-
additional_deployment_metrics(Gitlab::Prometheus::Queries::MatchedMetricsQuery.name, &:itself)
75+
with_reactive_cache(Gitlab::Prometheus::Queries::MatchedMetricsQuery.name, &:itself)
76+
end
77+
78+
def with_reactive_cache(*args, &block)
79+
yield calculate_reactive_cache(*args)
7680
end
7781

7882
# Cache metrics for specific environment

app/views/projects/services/_form.html.haml

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
- disabled_class = 'disabled'
2323
- disabled_title = @service.disabled_title
2424

25-
= link_to 'Test settings', test_namespace_project_service_path(@project.namespace, @project, @service), class: "btn #{disabled_class}", title: disabled_title
2625
= link_to 'Cancel', namespace_project_settings_integrations_path(@project.namespace, @project), class: 'btn btn-cancel'
2726

2827
- if lookup_context.template_exists?('show', "projects/services/#{@service.to_param}", true)

lib/gitlab/prometheus/additional_metrics_parser.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module AdditionalMetricsParser
44
extend self
55

66
def load_groups_from_yaml
7-
additional_metrics_raw.map(&method(:new))
7+
additional_metrics_raw.map(&method(:group_from_entry))
88
end
99

1010
private
@@ -25,7 +25,7 @@ def group_from_entry(entry)
2525
raise ParsingError.new("entry missing required fields #{missing_fields}") unless missing_fields.empty?
2626

2727
group = MetricGroup.new(entry[:group], entry[:priority])
28-
group.tap { |g| g.metrics = Metric.metrics_from_list(entry[:metrics]) }
28+
group.tap { |g| g.metrics = metrics_from_list(entry[:metrics]) }
2929
end
3030

3131
def additional_metrics_raw

lib/gitlab/prometheus/metric_group.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ class MetricGroup
44
attr_reader :priority, :name
55
attr_accessor :metrics
66

7-
def initialize(name:, priority:, metrics: [])
7+
def initialize(name, priority, metrics = [])
88
@name = name
99
@priority = priority
1010
@metrics = metrics

lib/gitlab/prometheus/queries/query_additional_metrics.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def group_with_any_metrics(group)
3737

3838
def query_with_result(query)
3939
query[:result]&.any? do |item|
40-
item&.[](:values)&.any? || item&.[](:value)&.any?
40+
item&.[]('values')&.any? || item&.[]('value')&.any?
4141
end
4242
end
4343

0 commit comments

Comments
 (0)