Sha256: ebcdf0932427589c1d6f9ec55ca900532b030a36757ee52b8d15e4c63abfca0d

Contents?: true

Size: 1.71 KB

Versions: 12

Compression:

Stored size: 1.71 KB

Contents

# frozen_string_literal: true

require_relative "../ext/telemetry"
require_relative "../ext/test"
require_relative "../utils/telemetry"
require_relative "../test_visibility/telemetry"

module Datadog
  module CI
    module TestOptimisation
      # Telemetry for test optimisation component
      module Telemetry
        def self.code_coverage_started(test)
          Utils::Telemetry.inc(Ext::Telemetry::METRIC_CODE_COVERAGE_STARTED, 1, tags_for_test(test))
        end

        def self.code_coverage_finished(test)
          Utils::Telemetry.inc(Ext::Telemetry::METRIC_CODE_COVERAGE_FINISHED, 1, tags_for_test(test))
        end

        def self.code_coverage_is_empty
          Utils::Telemetry.inc(Ext::Telemetry::METRIC_CODE_COVERAGE_IS_EMPTY, 1)
        end

        def self.code_coverage_files(count)
          Utils::Telemetry.distribution(Ext::Telemetry::METRIC_CODE_COVERAGE_FILES, count.to_f)
        end

        def self.itr_skipped
          Utils::Telemetry.inc(Ext::Telemetry::METRIC_ITR_SKIPPED, 1, tags_for_itr_metrics)
        end

        def self.itr_forced_run
          Utils::Telemetry.inc(Ext::Telemetry::METRIC_ITR_FORCED_RUN, 1, tags_for_itr_metrics)
        end

        def self.itr_unskippable
          Utils::Telemetry.inc(Ext::Telemetry::METRIC_ITR_UNSKIPPABLE, 1, tags_for_itr_metrics)
        end

        def self.tags_for_test(test)
          {
            Ext::Telemetry::TAG_TEST_FRAMEWORK => test.get_tag(Ext::Test::TAG_FRAMEWORK),
            Ext::Telemetry::TAG_LIBRARY => Ext::Telemetry::Library::CUSTOM
          }
        end

        def self.tags_for_itr_metrics
          {
            Ext::Telemetry::TAG_EVENT_TYPE => Ext::Telemetry::EventType::TEST
          }
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
datadog-ci-1.12.0 lib/datadog/ci/test_optimisation/telemetry.rb
datadog-ci-1.11.0 lib/datadog/ci/test_optimisation/telemetry.rb
datadog-ci-1.10.0 lib/datadog/ci/test_optimisation/telemetry.rb
datadog-ci-1.9.0 lib/datadog/ci/test_optimisation/telemetry.rb
datadog-ci-1.8.1 lib/datadog/ci/test_optimisation/telemetry.rb
datadog-ci-1.8.0 lib/datadog/ci/test_optimisation/telemetry.rb
datadog-ci-1.7.0 lib/datadog/ci/test_optimisation/telemetry.rb
datadog-ci-1.6.0 lib/datadog/ci/test_optimisation/telemetry.rb
datadog-ci-1.5.0 lib/datadog/ci/test_optimisation/telemetry.rb
datadog-ci-1.4.1 lib/datadog/ci/test_optimisation/telemetry.rb
datadog-ci-1.4.0 lib/datadog/ci/test_optimisation/telemetry.rb
datadog-ci-1.3.0 lib/datadog/ci/test_optimisation/telemetry.rb