lib/datadog/ci/transport/remote_settings_api.rb in datadog-ci-1.2.0 vs lib/datadog/ci/transport/remote_settings_api.rb in datadog-ci-1.3.0
- old
+ new
@@ -2,12 +2,15 @@
require "json"
require "datadog/core/environment/identity"
+require_relative "../ext/telemetry"
require_relative "../ext/transport"
+require_relative "../transport/telemetry"
require_relative "../utils/parsing"
+require_relative "../utils/telemetry"
module Datadog
module CI
module Transport
# Datadog API client
@@ -34,10 +37,18 @@
begin
@json = JSON.parse(resp.payload).dig(*Ext::Transport::DD_API_SETTINGS_RESPONSE_DIG_KEYS) ||
default_payload
rescue JSON::ParserError => e
Datadog.logger.error("Failed to parse settings response payload: #{e}. Payload was: #{resp.payload}")
+
+ Transport::Telemetry.api_requests_errors(
+ Ext::Telemetry::METRIC_GIT_REQUESTS_SETTINGS_ERRORS,
+ 1,
+ error_type: "invalid_json",
+ status_code: nil
+ )
+
@json = default_payload
end
end
def require_git?
@@ -67,10 +78,37 @@
http_response = api.api_request(
path: Ext::Transport::DD_API_SETTINGS_PATH,
payload: request_payload
)
- Response.new(http_response)
+ Transport::Telemetry.api_requests(
+ Ext::Telemetry::METRIC_GIT_REQUESTS_SETTINGS,
+ 1,
+ compressed: http_response.request_compressed
+ )
+ Utils::Telemetry.distribution(Ext::Telemetry::METRIC_GIT_REQUESTS_SETTINGS_MS, http_response.duration_ms)
+
+ unless http_response.ok?
+ Transport::Telemetry.api_requests_errors(
+ Ext::Telemetry::METRIC_GIT_REQUESTS_SETTINGS_ERRORS,
+ 1,
+ error_type: http_response.telemetry_error_type,
+ status_code: http_response.code
+ )
+ end
+
+ response = Response.new(http_response)
+
+ Utils::Telemetry.inc(
+ Ext::Telemetry::METRIC_GIT_REQUESTS_SETTINGS_RESPONSE,
+ 1,
+ {
+ Ext::Telemetry::TAG_COVERAGE_ENABLED => response.payload[Ext::Transport::DD_API_SETTINGS_RESPONSE_CODE_COVERAGE_KEY],
+ Ext::Telemetry::TAG_ITR_SKIP_ENABLED => response.payload[Ext::Transport::DD_API_SETTINGS_RESPONSE_TESTS_SKIPPING_KEY]
+ }
+ )
+
+ response
end
private
def payload(test_session)