Skip to content

Commit 06057f5

Browse files
committed
Add datadog VCR support
Adds support for Datadog API requests to the VCR server. Cassettes are added to assist in testing creating, searching and deleting datasets in the upcoming Datasets and Experiments product.
1 parent 27b370c commit 06057f5

9 files changed

+328
-1
lines changed

ddapm_test_agent/vcr_proxy.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"azure-openai": "https://dd.openai.azure.com/",
1515
"deepseek": "https://api.deepseek.com/",
1616
"anthropic": "https://api.anthropic.com/",
17+
"datadog": "https://api.datadoghq.com/",
1718
}
1819

1920
NORMALIZERS = [
@@ -59,7 +60,7 @@ def get_vcr(subdirectory: str, vcr_cassettes_directory: str) -> vcr.VCR:
5960
cassette_library_dir=cassette_dir,
6061
record_mode="once",
6162
match_on=["path", "method"],
62-
filter_headers=["authorization", "OpenAI-Organization", "api-key", "x-api-key"],
63+
filter_headers=["authorization", "OpenAI-Organization", "api-key", "x-api-key", "dd-api-key", "dd-application-key"],
6364
)
6465

6566

@@ -79,6 +80,8 @@ def generate_cassette_name(path: str, method: str, body: bytes) -> str:
7980

8081
async def proxy_request(request: Request, vcr_cassettes_directory: str) -> Response:
8182
path = request.match_info["path"]
83+
if request.query_string:
84+
path = path + "?" + request.query_string
8285

8386
parts = path.split("/", 1)
8487
if len(parts) != 2:
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
other:
3+
- |
4+
Add datadog vcr cassette support.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
interactions:
2+
- request:
3+
body: null
4+
headers:
5+
Accept:
6+
- '*/*'
7+
? !!python/object/new:multidict._multidict.istr
8+
- Accept-Encoding
9+
: - identity
10+
Connection:
11+
- keep-alive
12+
? !!python/object/new:multidict._multidict.istr
13+
- Content-Length
14+
: - '0'
15+
? !!python/object/new:multidict._multidict.istr
16+
- Content-Type
17+
: - application/json
18+
User-Agent:
19+
- python-requests/2.32.3
20+
method: GET
21+
uri: https://api.datadoghq.com/api/unstable/llm-obs/v1/datasets/7dc75245-7786-4417-b547-3e3eb868b287/records
22+
response:
23+
body:
24+
string: '{"data":[],"meta":{"after":""}}'
25+
headers:
26+
content-length:
27+
- '31'
28+
content-security-policy:
29+
- frame-ancestors 'self'; report-uri https://logs.browser-intake-datadoghq.com/api/v2/logs?dd-api-key=pube4f163c23bbf91c16b8f57f56af9fc58&dd-evp-origin=content-security-policy&ddsource=csp-report&ddtags=site%3Adatadoghq.com
30+
content-type:
31+
- application/vnd.api+json
32+
date:
33+
- Thu, 03 Jul 2025 05:29:34 GMT
34+
strict-transport-security:
35+
- max-age=31536000; includeSubDomains; preload
36+
vary:
37+
- Accept-Encoding
38+
x-content-type-options:
39+
- nosniff
40+
x-frame-options:
41+
- SAMEORIGIN
42+
status:
43+
code: 200
44+
message: OK
45+
version: 1
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
interactions:
2+
- request:
3+
body: '{"data": {"type": "datasets", "attributes": {"name": "test-dataset", "description":
4+
"A test dataset"}}}'
5+
headers:
6+
Accept:
7+
- '*/*'
8+
? !!python/object/new:multidict._multidict.istr
9+
- Accept-Encoding
10+
: - identity
11+
Connection:
12+
- keep-alive
13+
Content-Length:
14+
- '103'
15+
? !!python/object/new:multidict._multidict.istr
16+
- Content-Type
17+
: - application/json
18+
User-Agent:
19+
- python-requests/2.32.3
20+
method: POST
21+
uri: https://api.datadoghq.com/api/unstable/llm-obs/v1/datasets
22+
response:
23+
body:
24+
string: '{"data":{"id":"7dc75245-7786-4417-b547-3e3eb868b287","type":"datasets","attributes":{"author":{"id":"0dd9d379-c1a3-11ed-b4e0-566658a732f8"},"created_at":"2025-07-03T05:29:32.382174906Z","current_version":0,"description":"A
25+
test dataset","name":"test-dataset","updated_at":"2025-07-03T05:29:32.382174906Z"}}}'
26+
headers:
27+
content-length:
28+
- '307'
29+
content-security-policy:
30+
- frame-ancestors 'self'; report-uri https://logs.browser-intake-datadoghq.com/api/v2/logs?dd-api-key=pube4f163c23bbf91c16b8f57f56af9fc58&dd-evp-origin=content-security-policy&ddsource=csp-report&ddtags=site%3Adatadoghq.com
31+
content-type:
32+
- application/vnd.api+json
33+
date:
34+
- Thu, 03 Jul 2025 05:29:32 GMT
35+
strict-transport-security:
36+
- max-age=31536000; includeSubDomains; preload
37+
vary:
38+
- Accept-Encoding
39+
x-content-type-options:
40+
- nosniff
41+
x-frame-options:
42+
- SAMEORIGIN
43+
status:
44+
code: 200
45+
message: OK
46+
version: 1
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
interactions:
2+
- request:
3+
body: '{"data": {"type": "datasets", "attributes": {"name": "test-dataset-2",
4+
"description": "A second test dataset"}}}'
5+
headers:
6+
Accept:
7+
- '*/*'
8+
? !!python/object/new:multidict._multidict.istr
9+
- Accept-Encoding
10+
: - identity
11+
Connection:
12+
- keep-alive
13+
Content-Length:
14+
- '112'
15+
? !!python/object/new:multidict._multidict.istr
16+
- Content-Type
17+
: - application/json
18+
User-Agent:
19+
- python-requests/2.32.3
20+
method: POST
21+
uri: https://api.datadoghq.com/api/unstable/llm-obs/v1/datasets
22+
response:
23+
body:
24+
string: '{"data":{"id":"917877d8-83ef-4c53-a452-241de79ed5e8","type":"datasets","attributes":{"author":{"id":"0dd9d379-c1a3-11ed-b4e0-566658a732f8"},"created_at":"2025-07-03T05:29:31.299295288Z","current_version":0,"description":"A
25+
second test dataset","name":"test-dataset-2","updated_at":"2025-07-03T05:29:31.299295288Z"}}}'
26+
headers:
27+
content-length:
28+
- '316'
29+
content-security-policy:
30+
- frame-ancestors 'self'; report-uri https://logs.browser-intake-datadoghq.com/api/v2/logs?dd-api-key=pube4f163c23bbf91c16b8f57f56af9fc58&dd-evp-origin=content-security-policy&ddsource=csp-report&ddtags=site%3Adatadoghq.com
31+
content-type:
32+
- application/vnd.api+json
33+
date:
34+
- Thu, 03 Jul 2025 05:29:31 GMT
35+
strict-transport-security:
36+
- max-age=31536000; includeSubDomains; preload
37+
vary:
38+
- Accept-Encoding
39+
x-content-type-options:
40+
- nosniff
41+
x-frame-options:
42+
- SAMEORIGIN
43+
status:
44+
code: 200
45+
message: OK
46+
version: 1
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
interactions:
2+
- request:
3+
body: '{"data": {"type": "datasets", "attributes": {"type": "soft", "dataset_ids":
4+
["917877d8-83ef-4c53-a452-241de79ed5e8"]}}}'
5+
headers:
6+
Accept:
7+
- '*/*'
8+
? !!python/object/new:multidict._multidict.istr
9+
- Accept-Encoding
10+
: - identity
11+
Connection:
12+
- keep-alive
13+
Content-Length:
14+
- '119'
15+
? !!python/object/new:multidict._multidict.istr
16+
- Content-Type
17+
: - application/json
18+
User-Agent:
19+
- python-requests/2.32.3
20+
method: POST
21+
uri: https://api.datadoghq.com/api/unstable/llm-obs/v1/datasets/delete
22+
response:
23+
body:
24+
string: '{"data":[{"id":"917877d8-83ef-4c53-a452-241de79ed5e8","type":"datasets","attributes":{"author":{"id":"0dd9d379-c1a3-11ed-b4e0-566658a732f8"},"created_at":"2025-07-03T05:29:31.299295Z","current_version":0,"deleted_at":"2025-07-03T05:29:31.44429Z","description":"A
25+
second test dataset","name":"test-dataset-2","updated_at":"2025-07-03T05:29:31.299295Z"}}]}'
26+
headers:
27+
content-length:
28+
- '354'
29+
content-security-policy:
30+
- frame-ancestors 'self'; report-uri https://logs.browser-intake-datadoghq.com/api/v2/logs?dd-api-key=pube4f163c23bbf91c16b8f57f56af9fc58&dd-evp-origin=content-security-policy&ddsource=csp-report&ddtags=site%3Adatadoghq.com
31+
content-type:
32+
- application/vnd.api+json
33+
date:
34+
- Thu, 03 Jul 2025 05:29:31 GMT
35+
strict-transport-security:
36+
- max-age=31536000; includeSubDomains; preload
37+
vary:
38+
- Accept-Encoding
39+
x-content-type-options:
40+
- nosniff
41+
x-frame-options:
42+
- SAMEORIGIN
43+
status:
44+
code: 200
45+
message: OK
46+
version: 1
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
interactions:
2+
- request:
3+
body: '{"data": {"type": "datasets", "attributes": {"type": "soft", "dataset_ids":
4+
["7dc75245-7786-4417-b547-3e3eb868b287"]}}}'
5+
headers:
6+
Accept:
7+
- '*/*'
8+
? !!python/object/new:multidict._multidict.istr
9+
- Accept-Encoding
10+
: - identity
11+
Connection:
12+
- keep-alive
13+
Content-Length:
14+
- '119'
15+
? !!python/object/new:multidict._multidict.istr
16+
- Content-Type
17+
: - application/json
18+
User-Agent:
19+
- python-requests/2.32.3
20+
method: POST
21+
uri: https://api.datadoghq.com/api/unstable/llm-obs/v1/datasets/delete
22+
response:
23+
body:
24+
string: '{"data":[{"id":"7dc75245-7786-4417-b547-3e3eb868b287","type":"datasets","attributes":{"author":{"id":"0dd9d379-c1a3-11ed-b4e0-566658a732f8"},"created_at":"2025-07-03T05:29:32.382174Z","current_version":0,"deleted_at":"2025-07-03T05:29:34.628635Z","description":"A
25+
test dataset","name":"test-dataset","updated_at":"2025-07-03T05:29:32.382174Z"}}]}'
26+
headers:
27+
content-length:
28+
- '346'
29+
content-security-policy:
30+
- frame-ancestors 'self'; report-uri https://logs.browser-intake-datadoghq.com/api/v2/logs?dd-api-key=pube4f163c23bbf91c16b8f57f56af9fc58&dd-evp-origin=content-security-policy&ddsource=csp-report&ddtags=site%3Adatadoghq.com
31+
content-type:
32+
- application/vnd.api+json
33+
date:
34+
- Thu, 03 Jul 2025 05:29:34 GMT
35+
strict-transport-security:
36+
- max-age=31536000; includeSubDomains; preload
37+
vary:
38+
- Accept-Encoding
39+
x-content-type-options:
40+
- nosniff
41+
x-frame-options:
42+
- SAMEORIGIN
43+
status:
44+
code: 200
45+
message: OK
46+
version: 1
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
interactions:
2+
- request:
3+
body: null
4+
headers:
5+
Accept:
6+
- '*/*'
7+
? !!python/object/new:multidict._multidict.istr
8+
- Accept-Encoding
9+
: - identity
10+
Connection:
11+
- keep-alive
12+
? !!python/object/new:multidict._multidict.istr
13+
- Content-Length
14+
: - '0'
15+
? !!python/object/new:multidict._multidict.istr
16+
- Content-Type
17+
: - application/json
18+
User-Agent:
19+
- python-requests/2.32.3
20+
method: GET
21+
uri: https://api.datadoghq.com/api/unstable/llm-obs/v1/datasets?filter%5Bname%5D=test-dataset-non-existent
22+
response:
23+
body:
24+
string: '{"data":[],"meta":{"after":""}}'
25+
headers:
26+
content-length:
27+
- '31'
28+
content-security-policy:
29+
- frame-ancestors 'self'; report-uri https://logs.browser-intake-datadoghq.com/api/v2/logs?dd-api-key=pube4f163c23bbf91c16b8f57f56af9fc58&dd-evp-origin=content-security-policy&ddsource=csp-report&ddtags=site%3Adatadoghq.com
30+
content-type:
31+
- application/vnd.api+json
32+
date:
33+
- Thu, 03 Jul 2025 05:29:31 GMT
34+
strict-transport-security:
35+
- max-age=31536000; includeSubDomains; preload
36+
vary:
37+
- Accept-Encoding
38+
x-content-type-options:
39+
- nosniff
40+
x-frame-options:
41+
- SAMEORIGIN
42+
status:
43+
code: 200
44+
message: OK
45+
version: 1
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
interactions:
2+
- request:
3+
body: null
4+
headers:
5+
Accept:
6+
- '*/*'
7+
? !!python/object/new:multidict._multidict.istr
8+
- Accept-Encoding
9+
: - identity
10+
Connection:
11+
- keep-alive
12+
? !!python/object/new:multidict._multidict.istr
13+
- Content-Length
14+
: - '0'
15+
? !!python/object/new:multidict._multidict.istr
16+
- Content-Type
17+
: - application/json
18+
User-Agent:
19+
- python-requests/2.32.3
20+
method: GET
21+
uri: https://api.datadoghq.com/api/unstable/llm-obs/v1/datasets?filter%5Bname%5D=test-dataset
22+
response:
23+
body:
24+
string: '{"data":[{"id":"7dc75245-7786-4417-b547-3e3eb868b287","type":"datasets","attributes":{"author":{"id":"0dd9d379-c1a3-11ed-b4e0-566658a732f8"},"created_at":"2025-07-03T05:29:32.382174Z","current_version":0,"description":"A
25+
test dataset","name":"test-dataset","updated_at":"2025-07-03T05:29:32.382174Z"}}],"meta":{"after":""}}'
26+
headers:
27+
content-length:
28+
- '323'
29+
content-security-policy:
30+
- frame-ancestors 'self'; report-uri https://logs.browser-intake-datadoghq.com/api/v2/logs?dd-api-key=pube4f163c23bbf91c16b8f57f56af9fc58&dd-evp-origin=content-security-policy&ddsource=csp-report&ddtags=site%3Adatadoghq.com
31+
content-type:
32+
- application/vnd.api+json
33+
date:
34+
- Thu, 03 Jul 2025 05:29:33 GMT
35+
strict-transport-security:
36+
- max-age=31536000; includeSubDomains; preload
37+
vary:
38+
- Accept-Encoding
39+
x-content-type-options:
40+
- nosniff
41+
x-frame-options:
42+
- SAMEORIGIN
43+
status:
44+
code: 200
45+
message: OK
46+
version: 1

0 commit comments

Comments
 (0)