Module: Datadog::CI::Git::Telemetry

Defined in:
lib/datadog/ci/git/telemetry.rb

Class Method Summary collapse

Class Method Details

.exit_code_for(exit_code: nil, executable_missing: false) ⇒ Object



28
29
30
31
32
33
# File 'lib/datadog/ci/git/telemetry.rb', line 28

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

.git_command(command) ⇒ Object



7
8
9
# File 'lib/datadog/ci/git/telemetry.rb', line 7

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

.git_command_errors(command, exit_code: nil, executable_missing: false) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/datadog/ci/git/telemetry.rb', line 11

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

.git_command_ms(command, duration_ms) ⇒ Object



20
21
22
# File 'lib/datadog/ci/git/telemetry.rb', line 20

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

.tags_for_command(command) ⇒ Object



24
25
26
# File 'lib/datadog/ci/git/telemetry.rb', line 24

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