diff options
author | Pawel Chojnacki <pawel@chojnacki.ws> | 2017-06-08 12:29:53 +0200 |
---|---|---|
committer | Pawel Chojnacki <pawel@chojnacki.ws> | 2017-06-08 12:29:53 +0200 |
commit | f78fd3de5d55830c84f25cfd50d399e7ddaddf30 (patch) | |
tree | c03894b057000cc183a8e0b6b38642cc7325a00d | |
parent | 6eb96b2019d392d906a64108dbe83b3ce7cce758 (diff) | |
download | gitlab-ce-f78fd3de5d55830c84f25cfd50d399e7ddaddf30.tar.gz |
Fix Additional metrics filtering
+ remove test button that was leftover after a bad merge
-rw-r--r-- | app/models/project_services/prometheus_service.rb | 6 | ||||
-rw-r--r-- | app/views/projects/services/_form.html.haml | 1 | ||||
-rw-r--r-- | lib/gitlab/prometheus/additional_metrics_parser.rb | 4 | ||||
-rw-r--r-- | lib/gitlab/prometheus/metric_group.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/prometheus/queries/query_additional_metrics.rb | 2 |
5 files changed, 9 insertions, 6 deletions
diff --git a/app/models/project_services/prometheus_service.rb b/app/models/project_services/prometheus_service.rb index 1c4ae18c6ca..d81fec3514f 100644 --- a/app/models/project_services/prometheus_service.rb +++ b/app/models/project_services/prometheus_service.rb @@ -72,7 +72,11 @@ class PrometheusService < MonitoringService end def matched_metrics - additional_deployment_metrics(Gitlab::Prometheus::Queries::MatchedMetricsQuery.name, &:itself) + with_reactive_cache(Gitlab::Prometheus::Queries::MatchedMetricsQuery.name, &:itself) + end + + def with_reactive_cache(*args, &block) + yield calculate_reactive_cache(*args) end # Cache metrics for specific environment diff --git a/app/views/projects/services/_form.html.haml b/app/views/projects/services/_form.html.haml index cb3e1543fde..6dffc026392 100644 --- a/app/views/projects/services/_form.html.haml +++ b/app/views/projects/services/_form.html.haml @@ -22,7 +22,6 @@ - disabled_class = 'disabled' - disabled_title = @service.disabled_title - = link_to 'Test settings', test_namespace_project_service_path(@project.namespace, @project, @service), class: "btn #{disabled_class}", title: disabled_title = link_to 'Cancel', namespace_project_settings_integrations_path(@project.namespace, @project), class: 'btn btn-cancel' - if lookup_context.template_exists?('show', "projects/services/#{@service.to_param}", true) diff --git a/lib/gitlab/prometheus/additional_metrics_parser.rb b/lib/gitlab/prometheus/additional_metrics_parser.rb index 18eb79a44be..694001605ef 100644 --- a/lib/gitlab/prometheus/additional_metrics_parser.rb +++ b/lib/gitlab/prometheus/additional_metrics_parser.rb @@ -4,7 +4,7 @@ module Gitlab extend self def load_groups_from_yaml - additional_metrics_raw.map(&method(:new)) + additional_metrics_raw.map(&method(:group_from_entry)) end private @@ -25,7 +25,7 @@ module Gitlab raise ParsingError.new("entry missing required fields #{missing_fields}") unless missing_fields.empty? group = MetricGroup.new(entry[:group], entry[:priority]) - group.tap { |g| g.metrics = Metric.metrics_from_list(entry[:metrics]) } + group.tap { |g| g.metrics = metrics_from_list(entry[:metrics]) } end def additional_metrics_raw diff --git a/lib/gitlab/prometheus/metric_group.rb b/lib/gitlab/prometheus/metric_group.rb index c3b24dc1fa5..12bdf407ce0 100644 --- a/lib/gitlab/prometheus/metric_group.rb +++ b/lib/gitlab/prometheus/metric_group.rb @@ -4,7 +4,7 @@ module Gitlab attr_reader :priority, :name attr_accessor :metrics - def initialize(name:, priority:, metrics: []) + def initialize(name, priority, metrics = []) @name = name @priority = priority @metrics = metrics diff --git a/lib/gitlab/prometheus/queries/query_additional_metrics.rb b/lib/gitlab/prometheus/queries/query_additional_metrics.rb index dd888b2bc1d..a5a401f84cd 100644 --- a/lib/gitlab/prometheus/queries/query_additional_metrics.rb +++ b/lib/gitlab/prometheus/queries/query_additional_metrics.rb @@ -37,7 +37,7 @@ module Gitlab def query_with_result(query) query[:result]&.any? do |item| - item&.[](:values)&.any? || item&.[](:value)&.any? + item&.[]('values')&.any? || item&.[]('value')&.any? end end |