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

stubbed_service_ping_metrics_definitions_shared_context.rb « service_ping « services « shared_contexts « support « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 2b810e790f0eb9125f9b01b5b36bfed8b84322a1 (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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# frozen_string_literal: true

RSpec.shared_context 'stubbed service ping metrics definitions' do
  include UsageDataHelpers

  let(:metrics_definitions) { standard_metrics + subscription_metrics + operational_metrics + optional_metrics }
  let(:standard_metrics) do
    [
      metric_attributes('uuid', 'standard'),
      metric_attributes('recorded_at', 'standard'),
      metric_attributes('settings.collected_data_categories', 'standard', 'object')
    ]
  end

  let(:operational_metrics) do
    [
      metric_attributes('counts.merge_requests', 'operational'),
      metric_attributes('counts.todos', "operational")
    ]
  end

  let(:optional_metrics) do
    [
      metric_attributes('counts.boards', 'optional', 'number'),
      metric_attributes('gitaly.filesystems', '').except('data_category'),
      metric_attributes('usage_activity_by_stage.monitor.projects_with_enabled_alert_integrations_histogram', 'optional', 'object'),
      metric_attributes('topology', 'optional', 'object')
    ]
  end

  before do
    stub_usage_data_connections
    stub_object_store_settings

    allow(Gitlab::Usage::MetricDefinition).to(
      receive(:definitions)
        .and_return(metrics_definitions.to_h { |definition| [definition['key_path'], Gitlab::Usage::MetricDefinition.new('', definition.symbolize_keys)] })
    )
  end

  def metric_attributes(key_path, category, value_type = 'string')
    {
      'key_path' => key_path,
      'data_category' => category,
      'value_type' => value_type
    }
  end
end