diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index d9c881cd8367..6136c4fe7bae 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -42828,6 +42828,9 @@ components: description: Attributes of the SPA Recommendation resource. Contains recommendations for both driver and executor components. properties: + confidence_level: + format: double + type: number driver: $ref: '#/components/schemas/ComponentRecommendation' executor: @@ -86625,13 +86628,79 @@ paths: x-unstable: '**Note**: This feature is in private beta. To request access, use the request access form in the [Service Level Objectives](https://docs.datadoghq.com/service_management/service_level_objectives/#slo-csv-export) docs.' - /api/v2/spa/recommendations/{service}/{shard}: + /api/v2/spa/recommendations/{service}: get: - description: Retrieve resource recommendations for a Spark job. The caller (Spark - Gateway or DJM UI) provides a service name and shard identifier, and SPA returns - structured recommendations for driver and executor resources. + description: This endpoint is currently experimental and restricted to Datadog + internal use only. Retrieve resource recommendations for a Spark job. The + caller (Spark Gateway or DJM UI) provides a service name and SPA returns structured + recommendations for driver and executor resources. The version with a shard + should be preferred, where possible, as it gives more accurate results. operationId: GetSPARecommendations parameters: + - description: The recommendation service should not use its metrics cache. + in: query + name: bypass_cache + schema: + type: string + - description: The service name for a spark job. + in: path + name: service + required: true + schema: + type: string + responses: + '200': + content: + application/json: + example: + data: + attributes: + driver: + estimation: + cpu: + max: 1500 + p75: 1000 + p95: 1200 + ephemeral_storage: 896 + heap: 6144 + memory: 7168 + overhead: 1024 + executor: + estimation: + cpu: + max: 2000 + p75: 1200 + p95: 1500 + ephemeral_storage: 512 + heap: 3072 + memory: 4096 + overhead: 1024 + id: dedupeactivecontexts:adp_dedupeactivecontexts_org2 + type: recommendation + schema: + $ref: '#/components/schemas/RecommendationDocument' + description: OK + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/NotAuthorizedResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - AuthZ: [] + summary: Get SPA Recommendations + tags: + - Spa + x-unstable: '**Note**: This endpoint is in preview and may change in the future. + It is not yet recommended for production use.' + /api/v2/spa/recommendations/{service}/{shard}: + get: + description: This endpoint is currently experimental and restricted to Datadog + internal use only. Retrieve resource recommendations for a Spark job. The + caller (Spark Gateway or DJM UI) provides a service name and shard identifier, + and SPA returns structured recommendations for driver and executor resources. + operationId: GetSPARecommendationsWithShard + parameters: - description: The shard tag for a spark job, which differentiates jobs within the same service that have different resource needs in: path @@ -86645,6 +86714,11 @@ paths: required: true schema: type: string + - description: The recommendation service should not use its metrics cache. + in: query + name: bypass_cache + schema: + type: string responses: '200': content: @@ -86683,11 +86757,13 @@ paths: $ref: '#/components/responses/NotAuthorizedResponse' '429': $ref: '#/components/responses/TooManyRequestsResponse' - summary: Get SPA Recommendations + security: + - AuthZ: [] + summary: Get SPA Recommendations with a shard parameter tags: - Spa - x-unstable: '**Note**: This endpoint is in public beta and may change in the - future. It is not yet recommended for production use.' + x-unstable: '**Note**: This endpoint is in preview and may change in the future. + It is not yet recommended for production use.' /api/v2/spans/analytics/aggregate: post: description: 'The API endpoint to aggregate spans into buckets and compute metrics diff --git a/examples/v2/spa/GetSPARecommendations.rb b/examples/v2/spa/GetSPARecommendations.rb index 0234fd1e23cc..5c66dd77aefb 100644 --- a/examples/v2/spa/GetSPARecommendations.rb +++ b/examples/v2/spa/GetSPARecommendations.rb @@ -5,4 +5,4 @@ config.unstable_operations["v2.get_spa_recommendations".to_sym] = true end api_instance = DatadogAPIClient::V2::SpaAPI.new -p api_instance.get_spa_recommendations("shard", "service") +p api_instance.get_spa_recommendations("service") diff --git a/examples/v2/spa/GetSPARecommendationsWithShard.rb b/examples/v2/spa/GetSPARecommendationsWithShard.rb new file mode 100644 index 000000000000..b0e1e44fec69 --- /dev/null +++ b/examples/v2/spa/GetSPARecommendationsWithShard.rb @@ -0,0 +1,8 @@ +# Get SPA Recommendations with a shard parameter returns "OK" response + +require "datadog_api_client" +DatadogAPIClient.configure do |config| + config.unstable_operations["v2.get_spa_recommendations_with_shard".to_sym] = true +end +api_instance = DatadogAPIClient::V2::SpaAPI.new +p api_instance.get_spa_recommendations_with_shard("shard", "service") diff --git a/features/scenarios_model_mapping.rb b/features/scenarios_model_mapping.rb index 50840f4f7593..976270013450 100644 --- a/features/scenarios_model_mapping.rb +++ b/features/scenarios_model_mapping.rb @@ -3211,8 +3211,13 @@ "report_id" => "String", }, "v2.GetSPARecommendations" => { + "bypass_cache" => "String", + "service" => "String", + }, + "v2.GetSPARecommendationsWithShard" => { "shard" => "String", "service" => "String", + "bypass_cache" => "String", }, "v2.AggregateSpans" => { "body" => "SpansAggregateRequest", diff --git a/features/v2/spa.feature b/features/v2/spa.feature index 327bbf16ac09..0e6ac6b3a76b 100644 --- a/features/v2/spa.feature +++ b/features/v2/spa.feature @@ -4,29 +4,49 @@ Feature: Spa insights to help optimize Spark job configurations. Background: - Given a valid "apiKeyAuth" key in the system - And a valid "appKeyAuth" key in the system - And an instance of "Spa" API - And operation "GetSPARecommendations" enabled - And new "GetSPARecommendations" request + Given an instance of "Spa" API @generated @skip @team:DataDog/data-and-analytics-processing Scenario: Get SPA Recommendations returns "Bad Request" response - Given request contains "shard" parameter from "REPLACE.ME" + Given operation "GetSPARecommendations" enabled + And new "GetSPARecommendations" request And request contains "service" parameter from "REPLACE.ME" When the request is sent Then the response status is 400 Bad Request @generated @skip @team:DataDog/data-and-analytics-processing Scenario: Get SPA Recommendations returns "OK" response - Given request contains "shard" parameter from "REPLACE.ME" + Given operation "GetSPARecommendations" enabled + And new "GetSPARecommendations" request + And request contains "service" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/data-and-analytics-processing + Scenario: Get SPA Recommendations with a shard parameter returns "Bad Request" response + Given operation "GetSPARecommendationsWithShard" enabled + And new "GetSPARecommendationsWithShard" request + And request contains "shard" parameter from "REPLACE.ME" + And request contains "service" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/data-and-analytics-processing + Scenario: Get SPA Recommendations with a shard parameter returns "OK" response + Given operation "GetSPARecommendationsWithShard" enabled + And new "GetSPARecommendationsWithShard" request + And request contains "shard" parameter from "REPLACE.ME" And request contains "service" parameter from "REPLACE.ME" When the request is sent Then the response status is 200 OK @skip @team:DataDog/data-and-analytics-processing Scenario: GetSPARecommendations returns a JSON:API Recommendation with driver and executor estimations - Given request contains "service" parameter with value "dedupeactivecontexts" + Given new "GetSPARecommendations" request + And a valid "apiKeyAuth" key in the system + And a valid "appKeyAuth" key in the system + And operation "GetSPARecommendations" enabled + And request contains "service" parameter with value "dedupeactivecontexts" And request contains "shard" parameter with value "adp_dedupeactivecontexts_org2" When the request is sent Then the response status is 404 Not Found diff --git a/features/v2/undo.json b/features/v2/undo.json index b54378e93ba6..c6c7be164892 100644 --- a/features/v2/undo.json +++ b/features/v2/undo.json @@ -4484,6 +4484,12 @@ "type": "safe" } }, + "GetSPARecommendationsWithShard": { + "tag": "Spa", + "undo": { + "type": "safe" + } + }, "AggregateSpans": { "tag": "Spans", "undo": { diff --git a/lib/datadog_api_client/configuration.rb b/lib/datadog_api_client/configuration.rb index 3257b422c9b1..ee78a48c1934 100644 --- a/lib/datadog_api_client/configuration.rb +++ b/lib/datadog_api_client/configuration.rb @@ -334,6 +334,7 @@ def initialize "v2.get_slo_report": false, "v2.get_slo_report_job_status": false, "v2.get_spa_recommendations": false, + "v2.get_spa_recommendations_with_shard": false, "v2.create_sca_resolve_vulnerable_symbols": false, "v2.create_sca_result": false, "v2.add_member_team": false, diff --git a/lib/datadog_api_client/v2/api/spa_api.rb b/lib/datadog_api_client/v2/api/spa_api.rb index bfd9f0095fb0..62694b1ef38d 100644 --- a/lib/datadog_api_client/v2/api/spa_api.rb +++ b/lib/datadog_api_client/v2/api/spa_api.rb @@ -26,20 +26,20 @@ def initialize(api_client = DatadogAPIClient::APIClient.default) # Get SPA Recommendations. # # @see #get_spa_recommendations_with_http_info - def get_spa_recommendations(shard, service, opts = {}) - data, _status_code, _headers = get_spa_recommendations_with_http_info(shard, service, opts) + def get_spa_recommendations(service, opts = {}) + data, _status_code, _headers = get_spa_recommendations_with_http_info(service, opts) data end # Get SPA Recommendations. # - # Retrieve resource recommendations for a Spark job. The caller (Spark Gateway or DJM UI) provides a service name and shard identifier, and SPA returns structured recommendations for driver and executor resources. + # This endpoint is currently experimental and restricted to Datadog internal use only. Retrieve resource recommendations for a Spark job. The caller (Spark Gateway or DJM UI) provides a service name and SPA returns structured recommendations for driver and executor resources. The version with a shard should be preferred, where possible, as it gives more accurate results. # - # @param shard [String] The shard tag for a spark job, which differentiates jobs within the same service that have different resource needs - # @param service [String] The service name for a spark job + # @param service [String] The service name for a spark job. # @param opts [Hash] the optional parameters + # @option opts [String] :bypass_cache The recommendation service should not use its metrics cache. # @return [Array<(RecommendationDocument, Integer, Hash)>] RecommendationDocument data, response status code and response headers - def get_spa_recommendations_with_http_info(shard, service, opts = {}) + def get_spa_recommendations_with_http_info(service, opts = {}) unstable_enabled = @api_client.config.unstable_operations["v2.get_spa_recommendations".to_sym] if unstable_enabled @api_client.config.logger.warn format("Using unstable operation '%s'", "v2.get_spa_recommendations") @@ -50,19 +50,94 @@ def get_spa_recommendations_with_http_info(shard, service, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: SpaAPI.get_spa_recommendations ...' end + # verify the required parameter 'service' is set + if @api_client.config.client_side_validation && service.nil? + fail ArgumentError, "Missing the required parameter 'service' when calling SpaAPI.get_spa_recommendations" + end + # resource path + local_var_path = '/api/v2/spa/recommendations/{service}'.sub('{service}', CGI.escape(service.to_s).gsub('%2F', '/')) + + # query parameters + query_params = opts[:query_params] || {} + query_params[:'bypass_cache'] = opts[:'bypass_cache'] if !opts[:'bypass_cache'].nil? + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'RecommendationDocument' + + # auth_names + auth_names = opts[:debug_auth_names] || [:AuthZ] + + new_options = opts.merge( + :operation => :get_spa_recommendations, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + :api_version => "V2" + ) + + data, status_code, headers = @api_client.call_api(Net::HTTP::Get, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: SpaAPI#get_spa_recommendations\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Get SPA Recommendations with a shard parameter. + # + # @see #get_spa_recommendations_with_shard_with_http_info + def get_spa_recommendations_with_shard(shard, service, opts = {}) + data, _status_code, _headers = get_spa_recommendations_with_shard_with_http_info(shard, service, opts) + data + end + + # Get SPA Recommendations with a shard parameter. + # + # This endpoint is currently experimental and restricted to Datadog internal use only. Retrieve resource recommendations for a Spark job. The caller (Spark Gateway or DJM UI) provides a service name and shard identifier, and SPA returns structured recommendations for driver and executor resources. + # + # @param shard [String] The shard tag for a spark job, which differentiates jobs within the same service that have different resource needs + # @param service [String] The service name for a spark job + # @param opts [Hash] the optional parameters + # @option opts [String] :bypass_cache The recommendation service should not use its metrics cache. + # @return [Array<(RecommendationDocument, Integer, Hash)>] RecommendationDocument data, response status code and response headers + def get_spa_recommendations_with_shard_with_http_info(shard, service, opts = {}) + unstable_enabled = @api_client.config.unstable_operations["v2.get_spa_recommendations_with_shard".to_sym] + if unstable_enabled + @api_client.config.logger.warn format("Using unstable operation '%s'", "v2.get_spa_recommendations_with_shard") + else + raise DatadogAPIClient::APIError.new(message: format("Unstable operation '%s' is disabled", "v2.get_spa_recommendations_with_shard")) + end + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: SpaAPI.get_spa_recommendations_with_shard ...' + end # verify the required parameter 'shard' is set if @api_client.config.client_side_validation && shard.nil? - fail ArgumentError, "Missing the required parameter 'shard' when calling SpaAPI.get_spa_recommendations" + fail ArgumentError, "Missing the required parameter 'shard' when calling SpaAPI.get_spa_recommendations_with_shard" end # verify the required parameter 'service' is set if @api_client.config.client_side_validation && service.nil? - fail ArgumentError, "Missing the required parameter 'service' when calling SpaAPI.get_spa_recommendations" + fail ArgumentError, "Missing the required parameter 'service' when calling SpaAPI.get_spa_recommendations_with_shard" end # resource path local_var_path = '/api/v2/spa/recommendations/{service}/{shard}'.sub('{shard}', CGI.escape(shard.to_s).gsub('%2F', '/')).sub('{service}', CGI.escape(service.to_s).gsub('%2F', '/')) # query parameters query_params = opts[:query_params] || {} + query_params[:'bypass_cache'] = opts[:'bypass_cache'] if !opts[:'bypass_cache'].nil? # header parameters header_params = opts[:header_params] || {} @@ -79,10 +154,10 @@ def get_spa_recommendations_with_http_info(shard, service, opts = {}) return_type = opts[:debug_return_type] || 'RecommendationDocument' # auth_names - auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth] + auth_names = opts[:debug_auth_names] || [:AuthZ] new_options = opts.merge( - :operation => :get_spa_recommendations, + :operation => :get_spa_recommendations_with_shard, :header_params => header_params, :query_params => query_params, :form_params => form_params, @@ -94,7 +169,7 @@ def get_spa_recommendations_with_http_info(shard, service, opts = {}) data, status_code, headers = @api_client.call_api(Net::HTTP::Get, local_var_path, new_options) if @api_client.config.debugging - @api_client.config.logger.debug "API called: SpaAPI#get_spa_recommendations\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + @api_client.config.logger.debug "API called: SpaAPI#get_spa_recommendations_with_shard\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end diff --git a/lib/datadog_api_client/v2/models/recommendation_attributes.rb b/lib/datadog_api_client/v2/models/recommendation_attributes.rb index 2dce7efcf694..6c6945857b6f 100644 --- a/lib/datadog_api_client/v2/models/recommendation_attributes.rb +++ b/lib/datadog_api_client/v2/models/recommendation_attributes.rb @@ -21,6 +21,9 @@ module DatadogAPIClient::V2 class RecommendationAttributes include BaseGenericModel + # + attr_accessor :confidence_level + # Resource recommendation for a single Spark component (driver or executor). Contains estimation data used to patch Spark job specs. attr_reader :driver @@ -33,6 +36,7 @@ class RecommendationAttributes # @!visibility private def self.attribute_map { + :'confidence_level' => :'confidence_level', :'driver' => :'driver', :'executor' => :'executor' } @@ -42,6 +46,7 @@ def self.attribute_map # @!visibility private def self.openapi_types { + :'confidence_level' => :'Float', :'driver' => :'ComponentRecommendation', :'executor' => :'ComponentRecommendation' } @@ -65,6 +70,10 @@ def initialize(attributes = {}) end } + if attributes.key?(:'confidence_level') + self.confidence_level = attributes[:'confidence_level'] + end + if attributes.key?(:'driver') self.driver = attributes[:'driver'] end @@ -129,6 +138,7 @@ def to_hash def ==(o) return true if self.equal?(o) self.class == o.class && + confidence_level == o.confidence_level && driver == o.driver && executor == o.executor && additional_properties == o.additional_properties @@ -138,7 +148,7 @@ def ==(o) # @return [Integer] Hash code # @!visibility private def hash - [driver, executor, additional_properties].hash + [confidence_level, driver, executor, additional_properties].hash end end end