-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #205 from DataDog/anmarchenko/telemetry_metrics_gi…
…t_commands [SDTEST-160] git commands telemetry
- Loading branch information
Showing
14 changed files
with
332 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module Datadog | ||
module CI | ||
module Git | ||
module Telemetry | ||
def self.git_command: (String command) -> void | ||
|
||
def self.git_command_errors: (String command, ?exit_code: Integer?, ?executable_missing: bool) -> void | ||
|
||
def self.git_command_ms: (String command, untyped duration_ms) -> void | ||
|
||
def self.tags_for_command: (String command) -> ::Hash[String, String] | ||
|
||
def self.exit_code_for: (?exit_code: Integer?, ?executable_missing: bool) -> String? | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.