Class: GitlabInternalEventsCli::GlobalState

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab_internal_events_cli/global_state.rb

Instance Method Summary collapse

Instance Method Details

#eventsObject



6
7
8
9
10
11
12
# File 'lib/gitlab_internal_events_cli/global_state.rb', line 6

def events
  @events ||= load_definitions(
    Event,
    GitlabInternalEventsCli::NEW_EVENT_FIELDS,
    all_event_paths
  )
end

#metricsObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/gitlab_internal_events_cli/global_state.rb', line 14

def metrics
  @metrics ||= begin
    loaded_files = load_definitions(
      Metric,
      GitlabInternalEventsCli::NEW_METRIC_FIELDS,
      all_metric_paths
    )

    loaded_files.flat_map do |metric|
      # copy logic of Gitlab::Usage::MetricDefinition
      next metric unless metric.time_frame.is_a?(Array)

      metric.time_frame.map do |time_frame|
        current_metric = metric.dup
        current_metric.time_frame = time_frame
        current_metric.key_path = TimeFramedKeyPath.build(current_metric.key_path, time_frame)
        current_metric
      end
    end
  end
end

#reload_definitionsObject



36
37
38
39
# File 'lib/gitlab_internal_events_cli/global_state.rb', line 36

def reload_definitions
  @events = nil
  @metrics = nil
end