Sha256: b9b95af5165aa74eb27f09964cf6a2abe6d430ec7e883fa444cb9bac44ad0749

Contents?: true

Size: 1.18 KB

Versions: 12

Compression:

Stored size: 1.18 KB

Contents

# frozen_string_literal: true

module Datadog
  module CI
    module Git
      module Telemetry
        def self.git_command(command)
          Utils::Telemetry.inc(Ext::Telemetry::METRIC_GIT_COMMAND, 1, tags_for_command(command))
        end

        def self.git_command_errors(command, exit_code: nil, executable_missing: false)
          tags = tags_for_command(command)

          exit_code_tag_value = exit_code_for(exit_code: exit_code, executable_missing: executable_missing)
          tags[Ext::Telemetry::TAG_EXIT_CODE] = exit_code_tag_value if exit_code_tag_value

          Utils::Telemetry.inc(Ext::Telemetry::METRIC_GIT_COMMAND_ERRORS, 1, tags)
        end

        def self.git_command_ms(command, duration_ms)
          Utils::Telemetry.distribution(Ext::Telemetry::METRIC_GIT_COMMAND_MS, duration_ms, tags_for_command(command))
        end

        def self.tags_for_command(command)
          {Ext::Telemetry::TAG_COMMAND => command}
        end

        def self.exit_code_for(exit_code: nil, executable_missing: false)
          return Ext::Telemetry::ExitCode::MISSING if executable_missing
          return exit_code.to_s if exit_code

          nil
        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/git/telemetry.rb
datadog-ci-1.11.0 lib/datadog/ci/git/telemetry.rb
datadog-ci-1.10.0 lib/datadog/ci/git/telemetry.rb
datadog-ci-1.9.0 lib/datadog/ci/git/telemetry.rb
datadog-ci-1.8.1 lib/datadog/ci/git/telemetry.rb
datadog-ci-1.8.0 lib/datadog/ci/git/telemetry.rb
datadog-ci-1.7.0 lib/datadog/ci/git/telemetry.rb
datadog-ci-1.6.0 lib/datadog/ci/git/telemetry.rb
datadog-ci-1.5.0 lib/datadog/ci/git/telemetry.rb
datadog-ci-1.4.1 lib/datadog/ci/git/telemetry.rb
datadog-ci-1.4.0 lib/datadog/ci/git/telemetry.rb
datadog-ci-1.3.0 lib/datadog/ci/git/telemetry.rb