Skip to content

Commit 0c435ce

Browse files
opentelemetry-instrumentation-openai-v2: scrub cookie from tests
This scrubs test data and rewords token replacements corresponding to canonical ENV variables.o Before, we had inconsistent test data where most sensitive properties were set, but not all. Also, we scrubbed "api-key", but that is only set when using `AzureClient`, which this package doesn't use, yet. When it does, we should probably scrub more. The main thing this does is scrub out the request cookie, so that folks don't accidentally leak it in new PRs. After that, it helps clarify the source of sensitive data by making the replacement tokens match naming conventions of OpenAI ENV variables. See https://github.com/openai/openai-python/blob/646a579cdb305a9d3fba6c5f9a96011c5e2c2882/src/openai/_client.py#L98-L100 Signed-off-by: Adrian Cole <[email protected]>
1 parent b6a6f75 commit 0c435ce

12 files changed

+403
-336
lines changed

instrumentation-genai/opentelemetry-instrumentation-openai-v2/tests/cassettes/test_chat_completion_404.yaml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ interactions:
1515
- application/json
1616
accept-encoding:
1717
- gzip, deflate
18+
authorization:
19+
- Bearer test_openai_api_key
1820
connection:
1921
- keep-alive
2022
content-length:
@@ -58,13 +60,13 @@ interactions:
5860
CF-Cache-Status:
5961
- DYNAMIC
6062
CF-RAY:
61-
- 8e0ca7056be15f93-SIN
63+
- 8e1225a16c283d93-SIN
6264
Connection:
6365
- keep-alive
6466
Content-Type:
6567
- application/json; charset=utf-8
6668
Date:
67-
- Mon, 11 Nov 2024 07:43:38 GMT
69+
- Mon, 11 Nov 2024 23:43:52 GMT
6870
Server:
6971
- cloudflare
7072
Set-Cookie: test_set_cookie
@@ -76,13 +78,13 @@ interactions:
7678
- h3=":443"; ma=86400
7779
content-length:
7880
- '231'
79-
openai-organization: test_organization
81+
openai-organization: test_openai_org_id
8082
strict-transport-security:
8183
- max-age=31536000; includeSubDomains; preload
8284
vary:
8385
- Origin
8486
x-request-id:
85-
- req_75175efff56c313161c136c479e082ac
87+
- req_c3e0f92d7b5426d1a4a17bb3d39953ea
8688
status:
8789
code: 404
8890
message: Not Found

instrumentation-genai/opentelemetry-instrumentation-openai-v2/tests/cassettes/test_chat_completion_extra_params.yaml

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ interactions:
2020
- application/json
2121
accept-encoding:
2222
- gzip, deflate
23+
authorization:
24+
- Bearer test_openai_api_key
2325
connection:
2426
- keep-alive
2527
content-length:
@@ -29,7 +31,7 @@ interactions:
2931
host:
3032
- api.openai.com
3133
user-agent:
32-
- OpenAI/Python 1.26.0
34+
- OpenAI/Python 1.54.3
3335
x-stainless-arch:
3436
- arm64
3537
x-stainless-async:
@@ -39,7 +41,9 @@ interactions:
3941
x-stainless-os:
4042
- MacOS
4143
x-stainless-package-version:
42-
- 1.26.0
44+
- 1.54.3
45+
x-stainless-retry-count:
46+
- '0'
4347
x-stainless-runtime:
4448
- CPython
4549
x-stainless-runtime-version:
@@ -50,9 +54,9 @@ interactions:
5054
body:
5155
string: |-
5256
{
53-
"id": "chatcmpl-APfFNvBVQx43PNOIf1dWnEUT5u5fA",
57+
"id": "chatcmpl-ASYMT7913Sp58qhZqQgY7g7Ia2J4M",
5458
"object": "chat.completion",
55-
"created": 1730680117,
59+
"created": 1731368633,
5660
"model": "gpt-4o-mini-2024-07-18",
5761
"choices": [
5862
{
@@ -71,10 +75,14 @@ interactions:
7175
"completion_tokens": 12,
7276
"total_tokens": 24,
7377
"prompt_tokens_details": {
74-
"cached_tokens": 0
78+
"cached_tokens": 0,
79+
"audio_tokens": 0
7580
},
7681
"completion_tokens_details": {
77-
"reasoning_tokens": 0
82+
"reasoning_tokens": 0,
83+
"audio_tokens": 0,
84+
"accepted_prediction_tokens": 0,
85+
"rejected_prediction_tokens": 0
7886
}
7987
},
8088
"service_tier": "default",
@@ -84,13 +92,13 @@ interactions:
8492
CF-Cache-Status:
8593
- DYNAMIC
8694
CF-RAY:
87-
- 8dd07c2d0a5a9f98-SIN
95+
- 8e1225a3f8e9ce65-SIN
8896
Connection:
8997
- keep-alive
9098
Content-Type:
9199
- application/json
92100
Date:
93-
- Mon, 04 Nov 2024 00:28:37 GMT
101+
- Mon, 11 Nov 2024 23:43:53 GMT
94102
Server:
95103
- cloudflare
96104
Set-Cookie: test_set_cookie
@@ -103,10 +111,10 @@ interactions:
103111
alt-svc:
104112
- h3=":443"; ma=86400
105113
content-length:
106-
- '697'
107-
openai-organization: test_organization
114+
- '825'
115+
openai-organization: test_openai_org_id
108116
openai-processing-ms:
109-
- '228'
117+
- '431'
110118
openai-version:
111119
- '2020-10-01'
112120
strict-transport-security:
@@ -120,11 +128,11 @@ interactions:
120128
x-ratelimit-remaining-tokens:
121129
- '199943'
122130
x-ratelimit-reset-requests:
123-
- 13.724s
131+
- 14.746s
124132
x-ratelimit-reset-tokens:
125133
- 16ms
126134
x-request-id:
127-
- req_0ded46a4535c24c36ef58363b7538421
135+
- req_81e29a8992ea8001c0240bd990acf0ab
128136
status:
129137
code: 200
130138
message: OK

instrumentation-genai/opentelemetry-instrumentation-openai-v2/tests/cassettes/test_chat_completion_multiple_choices.yaml

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ interactions:
1717
- application/json
1818
accept-encoding:
1919
- gzip, deflate
20+
authorization:
21+
- Bearer test_openai_api_key
2022
connection:
2123
- keep-alive
2224
content-length:
@@ -26,7 +28,7 @@ interactions:
2628
host:
2729
- api.openai.com
2830
user-agent:
29-
- OpenAI/Python 1.26.0
31+
- OpenAI/Python 1.54.3
3032
x-stainless-arch:
3133
- arm64
3234
x-stainless-async:
@@ -36,7 +38,9 @@ interactions:
3638
x-stainless-os:
3739
- MacOS
3840
x-stainless-package-version:
39-
- 1.26.0
41+
- 1.54.3
42+
x-stainless-retry-count:
43+
- '0'
4044
x-stainless-runtime:
4145
- CPython
4246
x-stainless-runtime-version:
@@ -47,16 +51,16 @@ interactions:
4751
body:
4852
string: |-
4953
{
50-
"id": "chatcmpl-APfFO3w0cNVOphe5Lk9EaYyRaS2pm",
54+
"id": "chatcmpl-ASYMUBq69UHDarAz2fsd0O50rv0r1",
5155
"object": "chat.completion",
52-
"created": 1730680118,
56+
"created": 1731368634,
5357
"model": "gpt-4o-mini-2024-07-18",
5458
"choices": [
5559
{
5660
"index": 0,
5761
"message": {
5862
"role": "assistant",
59-
"content": "This is a test.",
63+
"content": "This is a test. How can I assist you further?",
6064
"refusal": null
6165
},
6266
"logprobs": null,
@@ -66,7 +70,7 @@ interactions:
6670
"index": 1,
6771
"message": {
6872
"role": "assistant",
69-
"content": "This is a test! How can I assist you further?",
73+
"content": "This is a test. How can I assist you further?",
7074
"refusal": null
7175
},
7276
"logprobs": null,
@@ -75,13 +79,17 @@ interactions:
7579
],
7680
"usage": {
7781
"prompt_tokens": 12,
78-
"completion_tokens": 17,
79-
"total_tokens": 29,
82+
"completion_tokens": 24,
83+
"total_tokens": 36,
8084
"prompt_tokens_details": {
81-
"cached_tokens": 0
85+
"cached_tokens": 0,
86+
"audio_tokens": 0
8287
},
8388
"completion_tokens_details": {
84-
"reasoning_tokens": 0
89+
"reasoning_tokens": 0,
90+
"audio_tokens": 0,
91+
"accepted_prediction_tokens": 0,
92+
"rejected_prediction_tokens": 0
8593
}
8694
},
8795
"system_fingerprint": "fp_0ba0d124f1"
@@ -90,13 +98,13 @@ interactions:
9098
CF-Cache-Status:
9199
- DYNAMIC
92100
CF-RAY:
93-
- 8dd07c30beda3dd4-SIN
101+
- 8e1225a91a253e53-SIN
94102
Connection:
95103
- keep-alive
96104
Content-Type:
97105
- application/json
98106
Date:
99-
- Mon, 04 Nov 2024 00:28:38 GMT
107+
- Mon, 11 Nov 2024 23:43:54 GMT
100108
Server:
101109
- cloudflare
102110
Set-Cookie: test_set_cookie
@@ -109,10 +117,10 @@ interactions:
109117
alt-svc:
110118
- h3=":443"; ma=86400
111119
content-length:
112-
- '872'
113-
openai-organization: test_organization
120+
- '1030'
121+
openai-organization: test_openai_org_id
114122
openai-processing-ms:
115-
- '261'
123+
- '399'
116124
openai-version:
117125
- '2020-10-01'
118126
strict-transport-security:
@@ -126,11 +134,11 @@ interactions:
126134
x-ratelimit-remaining-tokens:
127135
- '199962'
128136
x-ratelimit-reset-requests:
129-
- 21.785s
137+
- 22.564s
130138
x-ratelimit-reset-tokens:
131139
- 11ms
132140
x-request-id:
133-
- req_86ab6a7a85f95e2a001cfeb89e0827b1
141+
- req_01290a92a1a3d787c7a00bb3836da597
134142
status:
135143
code: 200
136144
message: OK

0 commit comments

Comments
 (0)