Class: ModularizationStatistics::Private::DatadogReporter
- Inherits:
-
Object
- Object
- ModularizationStatistics::Private::DatadogReporter
- Extended by:
- T::Sig
- Defined in:
- lib/modularization_statistics/private/datadog_reporter.rb
Class Method Summary collapse
- .get_metrics(source_code_files:, app_name:) ⇒ Object
- .report!(datadog_client:, report_time:, metrics:) ⇒ Object
Class Method Details
.get_metrics(source_code_files:, app_name:) ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/modularization_statistics/private/datadog_reporter.rb', line 25 def self.get_metrics(source_code_files:, app_name:) packages = ParsePackwerk.all [ *Metrics::Files.get_metrics(source_code_files, app_name), *Metrics::Packages.get_package_metrics(packages, app_name), *Metrics::PackagesByTeam.get_package_metrics_by_team(packages, app_name), *Metrics::NestedPacks.get_nested_package_metrics(packages, app_name) ] end |
.report!(datadog_client:, report_time:, metrics:) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/modularization_statistics/private/datadog_reporter.rb', line 45 def self.report!(datadog_client:, report_time:, metrics:) # # Batching the metrics sends a post request to DD # we want to split this up into chunks of 1000 so that as we add more metrics, # our payload is not rejected for being too large # metrics.each_slice(1000).each do |metric_slice| datadog_client.batch_metrics do metric_slice.each do |metric| datadog_client.emit_points(metric.name, [[report_time, metric.count]], type: 'gauge', tags: metric..map(&:to_s)) end end end end |