Welcome to mirror list, hosted at ThFree Co, Russian Federation.

issues_created_from_alerts_metric.rb « instrumentations « metrics « usage « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e430bc8eb71adcd87b54c6aea2909d4624b008b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# frozen_string_literal: true

module Gitlab
  module Usage
    module Metrics
      module Instrumentations
        class IssuesCreatedFromAlertsMetric < NumbersMetric
          ISSUES_FROM_ALERTS_METRICS = [
            IssuesWithAlertManagementAlertsMetric,
            IssuesWithPrometheusAlertEvents,
            IssuesWithSelfManagedPrometheusAlertEvents
          ].freeze

          operation :add

          data do |time_frame|
            ISSUES_FROM_ALERTS_METRICS.map { |metric| metric.new(time_frame: time_frame).value }
          end

          # overwriting instrumentation to generate the appropriate sql query
          def instrumentation
            'SELECT ' + ISSUES_FROM_ALERTS_METRICS.map do |metric|
              "(#{metric.new(time_frame: time_frame).instrumentation})"
            end.join(' + ')
          end
        end
      end
    end
  end
end