Class: Datadog::CI::Remote::LibrarySettingsClient
- Inherits:
-
Object
- Object
- Datadog::CI::Remote::LibrarySettingsClient
- Defined in:
- lib/datadog/ci/remote/library_settings_client.rb
Overview
Calls settings endpoint to fetch library settings for given service and env
Instance Method Summary collapse
- #fetch(test_session) ⇒ Object
-
#initialize(dd_env:, api: nil, config_tags: {}) ⇒ LibrarySettingsClient
constructor
A new instance of LibrarySettingsClient.
Constructor Details
#initialize(dd_env:, api: nil, config_tags: {}) ⇒ LibrarySettingsClient
Returns a new instance of LibrarySettingsClient.
20 21 22 23 24 |
# File 'lib/datadog/ci/remote/library_settings_client.rb', line 20 def initialize(dd_env:, api: nil, config_tags: {}) @api = api @dd_env = dd_env @config_tags = || {} end |
Instance Method Details
#fetch(test_session) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/datadog/ci/remote/library_settings_client.rb', line 26 def fetch(test_session) api = @api return LibrarySettings.new(nil) unless api request_payload = payload(test_session) Datadog.logger.debug("Fetching library settings with request: #{request_payload}") http_response = api.api_request( path: Ext::Transport::DD_API_SETTINGS_PATH, payload: request_payload ) 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 library_settings = LibrarySettings.new(http_response) Utils::Telemetry.inc( Ext::Telemetry::METRIC_GIT_REQUESTS_SETTINGS_RESPONSE, 1, { Ext::Telemetry::TAG_COVERAGE_ENABLED => library_settings.code_coverage_enabled?.to_s, Ext::Telemetry::TAG_ITR_SKIP_ENABLED => library_settings.tests_skipping_enabled?.to_s, Ext::Telemetry::TAG_EARLY_FLAKE_DETECTION_ENABLED => library_settings.early_flake_detection_enabled?.to_s } ) library_settings end |