Method: ModularizationStatistics.report_to_datadog!

Defined in:
lib/modularization_statistics.rb

.report_to_datadog!(datadog_client:, app_name:, source_code_pathnames:, componentized_source_code_locations: DEFAULT_COMPONENTIZED_SOURCE_CODE_LOCATIONS, packaged_source_code_locations: DEFAULT_PACKAGED_SOURCE_CODE_LOCATIONS, report_time: Time.now, verbose: false, use_gusto_legacy_names: false) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/modularization_statistics.rb', line 50

def self.report_to_datadog!(
  datadog_client:,
  app_name:,
  source_code_pathnames:,
  componentized_source_code_locations: DEFAULT_COMPONENTIZED_SOURCE_CODE_LOCATIONS,
  packaged_source_code_locations: DEFAULT_PACKAGED_SOURCE_CODE_LOCATIONS,
  report_time: Time.now, # rubocop:disable Rails/TimeZone
  verbose: false,
  use_gusto_legacy_names: false
)

  all_metrics = self.get_metrics(
    source_code_pathnames: source_code_pathnames,
    componentized_source_code_locations: componentized_source_code_locations,
    packaged_source_code_locations: packaged_source_code_locations,
    app_name: app_name,
    use_gusto_legacy_names: use_gusto_legacy_names,
  )

  # This helps us debug what metrics are being sent
  if verbose
    all_metrics.each do |metric|
      puts "Sending metric: #{metric}"
    end
  end

  if use_gusto_legacy_names
    all_metrics = Private.convert_metrics_to_legacy(all_metrics)
  end

  Private::DatadogReporter.report!(
    datadog_client: datadog_client,
    report_time: report_time,
    metrics: all_metrics
  )
end