Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 83 additions & 7 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion examples/v2/spa/GetSPARecommendations.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
with ApiClient(configuration) as api_client:
api_instance = SpaApi(api_client)
response = api_instance.get_spa_recommendations(
shard="shard",
service="service",
)

Expand Down
17 changes: 17 additions & 0 deletions examples/v2/spa/GetSPARecommendationsWithShard.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"""
Get SPA Recommendations with a shard parameter returns "OK" response
"""

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.spa_api import SpaApi

configuration = Configuration()
configuration.unstable_operations["get_spa_recommendations_with_shard"] = True
with ApiClient(configuration) as api_client:
api_instance = SpaApi(api_client)
response = api_instance.get_spa_recommendations_with_shard(
shard="shard",
service="service",
)

print(response)
1 change: 1 addition & 0 deletions src/datadog_api_client/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ def __init__(
"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,
Expand Down
80 changes: 74 additions & 6 deletions src/datadog_api_client/v2/api/spa_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
# Copyright 2019-Present Datadog, Inc.
from __future__ import annotations

from typing import Any, Dict
from typing import Any, Dict, Union

from datadog_api_client.api_client import ApiClient, Endpoint as _Endpoint
from datadog_api_client.configuration import Configuration
from datadog_api_client.model_utils import (
UnsetType,
unset,
)
from datadog_api_client.v2.model.recommendation_document import RecommendationDocument


Expand All @@ -23,12 +27,40 @@ def __init__(self, api_client=None):
self._get_spa_recommendations_endpoint = _Endpoint(
settings={
"response_type": (RecommendationDocument,),
"auth": ["apiKeyAuth", "appKeyAuth"],
"endpoint_path": "/api/v2/spa/recommendations/{service}/{shard}",
"auth": ["AuthZ"],
"endpoint_path": "/api/v2/spa/recommendations/{service}",
"operation_id": "get_spa_recommendations",
"http_method": "GET",
"version": "v2",
},
params_map={
"bypass_cache": {
"openapi_types": (str,),
"attribute": "bypass_cache",
"location": "query",
},
"service": {
"required": True,
"openapi_types": (str,),
"attribute": "service",
"location": "path",
},
},
headers_map={
"accept": ["application/json"],
},
api_client=api_client,
)

self._get_spa_recommendations_with_shard_endpoint = _Endpoint(
settings={
"response_type": (RecommendationDocument,),
"auth": ["AuthZ"],
"endpoint_path": "/api/v2/spa/recommendations/{service}/{shard}",
"operation_id": "get_spa_recommendations_with_shard",
"http_method": "GET",
"version": "v2",
},
params_map={
"shard": {
"required": True,
Expand All @@ -42,6 +74,11 @@ def __init__(self, api_client=None):
"attribute": "service",
"location": "path",
},
"bypass_cache": {
"openapi_types": (str,),
"attribute": "bypass_cache",
"location": "query",
},
},
headers_map={
"accept": ["application/json"],
Expand All @@ -51,22 +88,53 @@ def __init__(self, api_client=None):

def get_spa_recommendations(
self,
shard: str,
service: str,
*,
bypass_cache: Union[str, UnsetType] = unset,
) -> RecommendationDocument:
"""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 service: The service name for a spark job.
:type service: str
:param bypass_cache: The recommendation service should not use its metrics cache.
:type bypass_cache: str, optional
:rtype: RecommendationDocument
"""
kwargs: Dict[str, Any] = {}
if bypass_cache is not unset:
kwargs["bypass_cache"] = bypass_cache

kwargs["service"] = service

return self._get_spa_recommendations_endpoint.call_with_http_info(**kwargs)

def get_spa_recommendations_with_shard(
self,
shard: str,
service: str,
*,
bypass_cache: Union[str, UnsetType] = unset,
) -> RecommendationDocument:
"""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: The shard tag for a spark job, which differentiates jobs within the same service that have different resource needs
:type shard: str
:param service: The service name for a spark job
:type service: str
:param bypass_cache: The recommendation service should not use its metrics cache.
:type bypass_cache: str, optional
:rtype: RecommendationDocument
"""
kwargs: Dict[str, Any] = {}
kwargs["shard"] = shard

kwargs["service"] = service

return self._get_spa_recommendations_endpoint.call_with_http_info(**kwargs)
if bypass_cache is not unset:
kwargs["bypass_cache"] = bypass_cache

return self._get_spa_recommendations_with_shard_endpoint.call_with_http_info(**kwargs)
19 changes: 17 additions & 2 deletions src/datadog_api_client/v2/model/recommendation_attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
# Copyright 2019-Present Datadog, Inc.
from __future__ import annotations

from typing import TYPE_CHECKING
from typing import Union, TYPE_CHECKING

from datadog_api_client.model_utils import (
ModelNormal,
cached_property,
unset,
UnsetType,
)


Expand All @@ -21,25 +23,38 @@ def openapi_types(_):
from datadog_api_client.v2.model.component_recommendation import ComponentRecommendation

return {
"confidence_level": (float,),
"driver": (ComponentRecommendation,),
"executor": (ComponentRecommendation,),
}

attribute_map = {
"confidence_level": "confidence_level",
"driver": "driver",
"executor": "executor",
}

def __init__(self_, driver: ComponentRecommendation, executor: ComponentRecommendation, **kwargs):
def __init__(
self_,
driver: ComponentRecommendation,
executor: ComponentRecommendation,
confidence_level: Union[float, UnsetType] = unset,
**kwargs,
):
"""
Attributes of the SPA Recommendation resource. Contains recommendations for both driver and executor components.

:param confidence_level:
:type confidence_level: float, optional

:param driver: Resource recommendation for a single Spark component (driver or executor). Contains estimation data used to patch Spark job specs.
:type driver: ComponentRecommendation

:param executor: Resource recommendation for a single Spark component (driver or executor). Contains estimation data used to patch Spark job specs.
:type executor: ComponentRecommendation
"""
if confidence_level is not unset:
kwargs["confidence_level"] = confidence_level
super().__init__(kwargs)

self_.driver = driver
Expand Down
36 changes: 28 additions & 8 deletions tests/v2/features/spa.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading