Module: Gitlab::InternalEvents::EventDefinitions

Defined in:
lib/gitlab/internal_events/event_definitions.rb

Constant Summary collapse

InvalidMetricConfiguration =
Class.new(StandardError)
VALID_UNIQUE_VALUES =
%w[user.id project.id namespace.id].freeze

Class Method Summary collapse

Class Method Details

.load_configurationsObject



11
12
13
14
# File 'lib/gitlab/internal_events/event_definitions.rb', line 11

def load_configurations
  @events = load_metric_definitions
  nil
end

.unique_properties(event_name) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/gitlab/internal_events/event_definitions.rb', line 16

def unique_properties(event_name)
  unique_values = events.fetch(event_name, [])

  unique_values.filter_map do |unique_value|
    next unless unique_value # legacy events include `nil` unique_value

    unique_value = unique_value.to_s

    unless VALID_UNIQUE_VALUES.include?(unique_value)
      raise(InvalidMetricConfiguration, "Invalid unique value '#{unique_value}' for #{event_name}")
    end

    unique_value.split('.').first.to_sym
  end
end