Class: Datadog::CI::TestOptimisation::Skippable

Inherits:
Object
  • Object
show all
Defined in:
lib/datadog/ci/test_optimisation/skippable.rb

Defined Under Namespace

Classes: Response

Instance Method Summary collapse

Constructor Details

#initialize(dd_env:, api: nil, config_tags: {}) ⇒ Skippable

Returns a new instance of Skippable.



77
78
79
80
81
# File 'lib/datadog/ci/test_optimisation/skippable.rb', line 77

def initialize(dd_env:, api: nil, config_tags: {})
  @api = api
  @dd_env = dd_env
  @config_tags = config_tags
end

Instance Method Details

#fetch_skippable_tests(test_session) ⇒ Object



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/datadog/ci/test_optimisation/skippable.rb', line 83

def fetch_skippable_tests(test_session)
  api = @api
  return Response.from_http_response(nil) unless api

  request_payload = payload(test_session)
  Datadog.logger.debug("Fetching skippable tests with request: #{request_payload}")

  http_response = api.api_request(
    path: Ext::Transport::DD_API_SKIPPABLE_TESTS_PATH,
    payload: request_payload
  )

  Transport::Telemetry.api_requests(
    Ext::Telemetry::METRIC_ITR_SKIPPABLE_TESTS_REQUEST,
    1,
    compressed: http_response.request_compressed
  )
  Utils::Telemetry.distribution(Ext::Telemetry::METRIC_ITR_SKIPPABLE_TESTS_REQUEST_MS, http_response.duration_ms)
  Utils::Telemetry.distribution(
    Ext::Telemetry::METRIC_ITR_SKIPPABLE_TESTS_RESPONSE_BYTES,
    http_response.response_size.to_f,
    {Ext::Telemetry::TAG_RESPONSE_COMPRESSED => http_response.gzipped_content?.to_s}
  )

  unless http_response.ok?
    Transport::Telemetry.api_requests_errors(
      Ext::Telemetry::METRIC_ITR_SKIPPABLE_TESTS_REQUEST_ERRORS,
      1,
      error_type: http_response.telemetry_error_type,
      status_code: http_response.code
    )
  end

  Response.from_http_response(http_response)
end