Skip to content

Commit 3e3abbf

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
and
ci.datadog-api-spec
authored
Add trace_rate support to APM retention filter APIs (#2494)
Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent e80da31 commit 3e3abbf

File tree

30 files changed

+2287
-57
lines changed

30 files changed

+2287
-57
lines changed

.apigentools-info

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
"spec_versions": {
55
"v1": {
66
"apigentools_version": "1.6.6",
7-
"regenerated": "2025-04-08 14:37:44.703187",
8-
"spec_repo_commit": "642b7d0b"
7+
"regenerated": "2025-04-08 20:00:50.307792",
8+
"spec_repo_commit": "3e2afa30"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.6",
12-
"regenerated": "2025-04-08 14:37:44.802514",
13-
"spec_repo_commit": "642b7d0b"
12+
"regenerated": "2025-04-08 20:00:50.398680",
13+
"spec_repo_commit": "3e2afa30"
1414
}
1515
}
1616
}

.generator/schemas/v2/openapi.yaml

+32
Original file line numberDiff line numberDiff line change
@@ -25238,6 +25238,14 @@ components:
2523825238
example: 1.0
2523925239
format: double
2524025240
type: number
25241+
trace_rate:
25242+
description: 'Sample rate to apply to traces containing spans going through
25243+
this retention filter.
25244+
25245+
A value of 1.0 keeps all traces with spans matching the query.'
25246+
example: 1.0
25247+
format: double
25248+
type: number
2524125249
type: object
2524225250
RetentionFilterAllType:
2524325251
default: spans-sampling-processor
@@ -25297,6 +25305,14 @@ components:
2529725305
example: 1.0
2529825306
format: double
2529925307
type: number
25308+
trace_rate:
25309+
description: 'Sample rate to apply to traces containing spans going through
25310+
this retention filter.
25311+
25312+
A value of 1.0 keeps all traces with spans matching the query.'
25313+
example: 1.0
25314+
format: double
25315+
type: number
2530025316
type: object
2530125317
RetentionFilterCreateAttributes:
2530225318
description: The object describing the configuration of the retention filter
@@ -25322,6 +25338,14 @@ components:
2532225338
example: 1.0
2532325339
format: double
2532425340
type: number
25341+
trace_rate:
25342+
description: 'Sample rate to apply to traces containing spans going through
25343+
this retention filter.
25344+
25345+
A value of 1.0 keeps all traces with spans matching the query.'
25346+
example: 1.0
25347+
format: double
25348+
type: number
2532525349
required:
2532625350
- name
2532725351
- filter
@@ -25393,6 +25417,14 @@ components:
2539325417
example: 1.0
2539425418
format: double
2539525419
type: number
25420+
trace_rate:
25421+
description: 'Sample rate to apply to traces containing spans going through
25422+
this retention filter.
25423+
25424+
A value of 1.0 keeps all traces with spans matching the query.'
25425+
example: 1.0
25426+
format: double
25427+
type: number
2539625428
required:
2539725429
- name
2539825430
- filter
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
"""
2+
Create a retention filter with trace rate returns "OK" response
3+
"""
4+
5+
from datadog_api_client import ApiClient, Configuration
6+
from datadog_api_client.v2.api.apm_retention_filters_api import APMRetentionFiltersApi
7+
from datadog_api_client.v2.model.apm_retention_filter_type import ApmRetentionFilterType
8+
from datadog_api_client.v2.model.retention_filter_create_attributes import RetentionFilterCreateAttributes
9+
from datadog_api_client.v2.model.retention_filter_create_data import RetentionFilterCreateData
10+
from datadog_api_client.v2.model.retention_filter_create_request import RetentionFilterCreateRequest
11+
from datadog_api_client.v2.model.retention_filter_type import RetentionFilterType
12+
from datadog_api_client.v2.model.spans_filter_create import SpansFilterCreate
13+
14+
body = RetentionFilterCreateRequest(
15+
data=RetentionFilterCreateData(
16+
attributes=RetentionFilterCreateAttributes(
17+
enabled=True,
18+
filter=SpansFilterCreate(
19+
query="@http.status_code:200 service:my-service",
20+
),
21+
filter_type=RetentionFilterType.SPANS_SAMPLING_PROCESSOR,
22+
name="my retention filter",
23+
rate=1.0,
24+
trace_rate=1.0,
25+
),
26+
type=ApmRetentionFilterType.apm_retention_filter,
27+
),
28+
)
29+
30+
configuration = Configuration()
31+
with ApiClient(configuration) as api_client:
32+
api_instance = APMRetentionFiltersApi(api_client)
33+
response = api_instance.create_apm_retention_filter(body=body)
34+
35+
print(response)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
"""
2+
Update a retention filter with trace rate returns "OK" response
3+
"""
4+
5+
from os import environ
6+
from datadog_api_client import ApiClient, Configuration
7+
from datadog_api_client.v2.api.apm_retention_filters_api import APMRetentionFiltersApi
8+
from datadog_api_client.v2.model.apm_retention_filter_type import ApmRetentionFilterType
9+
from datadog_api_client.v2.model.retention_filter_all_type import RetentionFilterAllType
10+
from datadog_api_client.v2.model.retention_filter_update_attributes import RetentionFilterUpdateAttributes
11+
from datadog_api_client.v2.model.retention_filter_update_data import RetentionFilterUpdateData
12+
from datadog_api_client.v2.model.retention_filter_update_request import RetentionFilterUpdateRequest
13+
from datadog_api_client.v2.model.spans_filter_create import SpansFilterCreate
14+
15+
# there is a valid "retention_filter" in the system
16+
RETENTION_FILTER_DATA_ID = environ["RETENTION_FILTER_DATA_ID"]
17+
18+
body = RetentionFilterUpdateRequest(
19+
data=RetentionFilterUpdateData(
20+
attributes=RetentionFilterUpdateAttributes(
21+
name="test",
22+
rate=0.9,
23+
trace_rate=1.0,
24+
filter=SpansFilterCreate(
25+
query="@_top_level:1 test:service-demo",
26+
),
27+
enabled=True,
28+
filter_type=RetentionFilterAllType.SPANS_SAMPLING_PROCESSOR,
29+
),
30+
id="test-id",
31+
type=ApmRetentionFilterType.apm_retention_filter,
32+
),
33+
)
34+
35+
configuration = Configuration()
36+
with ApiClient(configuration) as api_client:
37+
api_instance = APMRetentionFiltersApi(api_client)
38+
response = api_instance.update_apm_retention_filter(filter_id=RETENTION_FILTER_DATA_ID, body=body)
39+
40+
print(response)

src/datadog_api_client/v2/model/retention_filter_all_attributes.py

+9
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ def openapi_types(_):
3636
"modified_by": (str,),
3737
"name": (str,),
3838
"rate": (float,),
39+
"trace_rate": (float,),
3940
}
4041

4142
attribute_map = {
@@ -50,6 +51,7 @@ def openapi_types(_):
5051
"modified_by": "modified_by",
5152
"name": "name",
5253
"rate": "rate",
54+
"trace_rate": "trace_rate",
5355
}
5456

5557
def __init__(
@@ -65,6 +67,7 @@ def __init__(
6567
modified_by: Union[str, UnsetType] = unset,
6668
name: Union[str, UnsetType] = unset,
6769
rate: Union[float, UnsetType] = unset,
70+
trace_rate: Union[float, UnsetType] = unset,
6871
**kwargs,
6972
):
7073
"""
@@ -103,6 +106,10 @@ def __init__(
103106
:param rate: Sample rate to apply to spans going through this retention filter,
104107
a value of 1.0 keeps all spans matching the query.
105108
:type rate: float, optional
109+
110+
:param trace_rate: Sample rate to apply to traces containing spans going through this retention filter.
111+
A value of 1.0 keeps all traces with spans matching the query.
112+
:type trace_rate: float, optional
106113
"""
107114
if created_at is not unset:
108115
kwargs["created_at"] = created_at
@@ -126,4 +133,6 @@ def __init__(
126133
kwargs["name"] = name
127134
if rate is not unset:
128135
kwargs["rate"] = rate
136+
if trace_rate is not unset:
137+
kwargs["trace_rate"] = trace_rate
129138
super().__init__(kwargs)

src/datadog_api_client/v2/model/retention_filter_attributes.py

+9
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ def openapi_types(_):
3636
"modified_by": (str,),
3737
"name": (str,),
3838
"rate": (float,),
39+
"trace_rate": (float,),
3940
}
4041

4142
attribute_map = {
@@ -50,6 +51,7 @@ def openapi_types(_):
5051
"modified_by": "modified_by",
5152
"name": "name",
5253
"rate": "rate",
54+
"trace_rate": "trace_rate",
5355
}
5456

5557
def __init__(
@@ -65,6 +67,7 @@ def __init__(
6567
modified_by: Union[str, UnsetType] = unset,
6668
name: Union[str, UnsetType] = unset,
6769
rate: Union[float, UnsetType] = unset,
70+
trace_rate: Union[float, UnsetType] = unset,
6871
**kwargs,
6972
):
7073
"""
@@ -103,6 +106,10 @@ def __init__(
103106
:param rate: Sample rate to apply to spans going through this retention filter,
104107
a value of 1.0 keeps all spans matching the query.
105108
:type rate: float, optional
109+
110+
:param trace_rate: Sample rate to apply to traces containing spans going through this retention filter.
111+
A value of 1.0 keeps all traces with spans matching the query.
112+
:type trace_rate: float, optional
106113
"""
107114
if created_at is not unset:
108115
kwargs["created_at"] = created_at
@@ -126,4 +133,6 @@ def __init__(
126133
kwargs["name"] = name
127134
if rate is not unset:
128135
kwargs["rate"] = rate
136+
if trace_rate is not unset:
137+
kwargs["trace_rate"] = trace_rate
129138
super().__init__(kwargs)

src/datadog_api_client/v2/model/retention_filter_create_attributes.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
# Copyright 2019-Present Datadog, Inc.
44
from __future__ import annotations
55

6-
from typing import TYPE_CHECKING
6+
from typing import Union, TYPE_CHECKING
77

88
from datadog_api_client.model_utils import (
99
ModelNormal,
1010
cached_property,
11+
unset,
12+
UnsetType,
1113
)
1214

1315

@@ -28,6 +30,7 @@ def openapi_types(_):
2830
"filter_type": (RetentionFilterType,),
2931
"name": (str,),
3032
"rate": (float,),
33+
"trace_rate": (float,),
3134
}
3235

3336
attribute_map = {
@@ -36,6 +39,7 @@ def openapi_types(_):
3639
"filter_type": "filter_type",
3740
"name": "name",
3841
"rate": "rate",
42+
"trace_rate": "trace_rate",
3943
}
4044

4145
def __init__(
@@ -45,6 +49,7 @@ def __init__(
4549
filter_type: RetentionFilterType,
4650
name: str,
4751
rate: float,
52+
trace_rate: Union[float, UnsetType] = unset,
4853
**kwargs,
4954
):
5055
"""
@@ -65,7 +70,13 @@ def __init__(
6570
:param rate: Sample rate to apply to spans going through this retention filter,
6671
a value of 1.0 keeps all spans matching the query.
6772
:type rate: float
73+
74+
:param trace_rate: Sample rate to apply to traces containing spans going through this retention filter.
75+
A value of 1.0 keeps all traces with spans matching the query.
76+
:type trace_rate: float, optional
6877
"""
78+
if trace_rate is not unset:
79+
kwargs["trace_rate"] = trace_rate
6980
super().__init__(kwargs)
7081

7182
self_.enabled = enabled

src/datadog_api_client/v2/model/retention_filter_update_attributes.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
# Copyright 2019-Present Datadog, Inc.
44
from __future__ import annotations
55

6-
from typing import TYPE_CHECKING
6+
from typing import Union, TYPE_CHECKING
77

88
from datadog_api_client.model_utils import (
99
ModelNormal,
1010
cached_property,
11+
unset,
12+
UnsetType,
1113
)
1214

1315

@@ -28,6 +30,7 @@ def openapi_types(_):
2830
"filter_type": (RetentionFilterAllType,),
2931
"name": (str,),
3032
"rate": (float,),
33+
"trace_rate": (float,),
3134
}
3235

3336
attribute_map = {
@@ -36,6 +39,7 @@ def openapi_types(_):
3639
"filter_type": "filter_type",
3740
"name": "name",
3841
"rate": "rate",
42+
"trace_rate": "trace_rate",
3943
}
4044

4145
def __init__(
@@ -45,6 +49,7 @@ def __init__(
4549
filter_type: RetentionFilterAllType,
4650
name: str,
4751
rate: float,
52+
trace_rate: Union[float, UnsetType] = unset,
4853
**kwargs,
4954
):
5055
"""
@@ -65,7 +70,13 @@ def __init__(
6570
:param rate: Sample rate to apply to spans going through this retention filter,
6671
a value of 1.0 keeps all spans matching the query.
6772
:type rate: float
73+
74+
:param trace_rate: Sample rate to apply to traces containing spans going through this retention filter.
75+
A value of 1.0 keeps all traces with spans matching the query.
76+
:type trace_rate: float, optional
6877
"""
78+
if trace_rate is not unset:
79+
kwargs["trace_rate"] = trace_rate
6980
super().__init__(kwargs)
7081

7182
self_.enabled = enabled
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2024-04-10T12:31:19.300Z
1+
2025-04-08T11:32:44.101Z
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2023-09-21T16:39:02.926Z
1+
2025-04-08T11:32:44.623Z
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2023-10-19T12:28:01.048Z
1+
2025-04-08T11:32:45.098Z

tests/v2/cassettes/test_scenarios/test_create_a_retention_filter_returns_ok_response.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ interactions:
1212
uri: https://api.datadoghq.com/api/v2/apm/config/retention-filters
1313
response:
1414
body:
15-
string: '{"data":{"id":"kkZkTzFaR_Oy4OWzOJQbcw","attributes":{"name":"my retention
16-
filter","rate":1.0,"enabled":true,"filter_type":"spans-sampling-processor","filter":{"query":"@http.status_code:200
17-
service:my-service"},"editable":true,"modified_by":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","modified_at":1697718481,"created_by":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","created_at":1697718481},"type":"apm_retention_filter"}}
15+
string: '{"data":{"id":"x1aRVkAVQN2CBx1ghs4xDQ","attributes":{"name":"my retention
16+
filter","rate":1.0,"trace_rate":0.0,"enabled":true,"filter_type":"spans-sampling-processor","filter":{"query":"@http.status_code:200
17+
service:my-service"},"editable":true,"modified_by":"[email protected]","modified_at":1744111965,"created_by":"[email protected]","created_at":1744111965},"type":"apm_retention_filter"}}
1818
1919
'
2020
headers:
@@ -29,7 +29,7 @@ interactions:
2929
accept:
3030
- '*/*'
3131
method: DELETE
32-
uri: https://api.datadoghq.com/api/v2/apm/config/retention-filters/kkZkTzFaR_Oy4OWzOJQbcw
32+
uri: https://api.datadoghq.com/api/v2/apm/config/retention-filters/x1aRVkAVQN2CBx1ghs4xDQ
3333
response:
3434
body:
3535
string: '{}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2025-04-08T11:32:46.074Z

0 commit comments

Comments
 (0)