Skip to content

Commit 29b43de

Browse files
authored
Merge branch 'main' into fix-system-metrics-win
2 parents 04eff1b + d6a59e4 commit 29b43de

15 files changed

+1063
-801
lines changed

instrumentation-genai/opentelemetry-instrumentation-openai-v2/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## Unreleased
99

10+
- Use generic `OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT` environment variable
11+
to control if content of prompt, completion, and other messages is captured.
12+
([#2947](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2947))
13+
1014
- Update OpenAI instrumentation to Semantic Conventions v1.28.0: add new attributes
1115
and switch prompts and completions to log-based events.
1216
([#2925](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2925))

instrumentation-genai/opentelemetry-instrumentation-openai-v2/src/opentelemetry/instrumentation/openai_v2/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@
2727
server_attributes as ServerAttributes,
2828
)
2929

30-
OTEL_INSTRUMENTATION_OPENAI_CAPTURE_MESSAGE_CONTENT = (
31-
"OTEL_INSTRUMENTATION_OPENAI_CAPTURE_MESSAGE_CONTENT"
30+
OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT = (
31+
"OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT"
3232
)
3333

3434

3535
def is_content_enabled() -> bool:
3636
capture_content = environ.get(
37-
OTEL_INSTRUMENTATION_OPENAI_CAPTURE_MESSAGE_CONTENT, "false"
37+
OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT, "false"
3838
)
3939

4040
return capture_content.lower() == "true"

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

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
interactions:
22
- request:
3-
body: '{"messages": [{"role": "user", "content": "Say this is a test"}], "model":
4-
"this-model-does-not-exist"}'
3+
body: |-
4+
{
5+
"messages": [
6+
{
7+
"role": "user",
8+
"content": "Say this is a test"
9+
}
10+
],
11+
"model": "this-model-does-not-exist"
12+
}
513
headers:
614
accept:
715
- application/json
@@ -16,41 +24,45 @@ interactions:
1624
host:
1725
- api.openai.com
1826
user-agent:
19-
- OpenAI/Python 1.52.2
27+
- OpenAI/Python 1.26.0
2028
x-stainless-arch:
21-
- other:amd64
29+
- arm64
2230
x-stainless-async:
2331
- 'false'
2432
x-stainless-lang:
2533
- python
2634
x-stainless-os:
27-
- Windows
35+
- MacOS
2836
x-stainless-package-version:
29-
- 1.52.2
30-
x-stainless-retry-count:
31-
- '2'
37+
- 1.26.0
3238
x-stainless-runtime:
3339
- CPython
3440
x-stainless-runtime-version:
35-
- 3.12.7
41+
- 3.12.6
3642
method: POST
3743
uri: https://api.openai.com/v1/chat/completions
3844
response:
3945
body:
40-
string: "{\n \"error\": {\n \"message\": \"The model `this-model-does-not-exist`
41-
does not exist or you do not have access to it.\",\n \"type\": \"invalid_request_error\",\n
42-
\ \"param\": null,\n \"code\": \"model_not_found\"\n }\n}\n"
46+
string: |-
47+
{
48+
"error": {
49+
"message": "The model `this-model-does-not-exist` does not exist or you do not have access to it.",
50+
"type": "invalid_request_error",
51+
"param": null,
52+
"code": "model_not_found"
53+
}
54+
}
4355
headers:
4456
CF-Cache-Status:
4557
- DYNAMIC
4658
CF-RAY:
47-
- 8d88b04c2c5db9eb-SEA
59+
- 8dd0709dffd19c8c-SIN
4860
Connection:
4961
- keep-alive
5062
Content-Type:
5163
- application/json; charset=utf-8
5264
Date:
53-
- Sat, 26 Oct 2024 07:21:17 GMT
65+
- Mon, 04 Nov 2024 00:20:44 GMT
5466
Server:
5567
- cloudflare
5668
Set-Cookie: test_set_cookie
@@ -68,7 +80,7 @@ interactions:
6880
vary:
6981
- Origin
7082
x-request-id:
71-
- req_8529656422f0360e8bcba8c2b8fe34e9
83+
- req_e08854c4f7d5104af6fdc755caed30fc
7284
status:
7385
code: 404
7486
message: Not Found

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

Lines changed: 63 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
11
interactions:
22
- request:
3-
body: '{"messages": [{"role": "user", "content": "Say this is a test"}], "model":
4-
"gpt-4o-mini", "max_tokens": 50, "seed": 42, "service_tier": "auto", "stream":
5-
false, "temperature": 0.5}'
3+
body: |-
4+
{
5+
"messages": [
6+
{
7+
"role": "user",
8+
"content": "Say this is a test"
9+
}
10+
],
11+
"model": "gpt-4o-mini",
12+
"max_tokens": 50,
13+
"seed": 42,
14+
"stream": false,
15+
"temperature": 0.5,
16+
"service_tier": "default"
17+
}
618
headers:
719
accept:
820
- application/json
@@ -11,54 +23,74 @@ interactions:
1123
connection:
1224
- keep-alive
1325
content-length:
14-
- '180'
26+
- '183'
1527
content-type:
1628
- application/json
1729
host:
1830
- api.openai.com
1931
user-agent:
20-
- OpenAI/Python 1.52.2
32+
- OpenAI/Python 1.26.0
2133
x-stainless-arch:
22-
- other:amd64
34+
- arm64
2335
x-stainless-async:
2436
- 'false'
2537
x-stainless-lang:
2638
- python
2739
x-stainless-os:
28-
- Windows
40+
- MacOS
2941
x-stainless-package-version:
30-
- 1.52.2
31-
x-stainless-retry-count:
32-
- '0'
42+
- 1.26.0
3343
x-stainless-runtime:
3444
- CPython
3545
x-stainless-runtime-version:
36-
- 3.12.7
46+
- 3.12.6
3747
method: POST
3848
uri: https://api.openai.com/v1/chat/completions
3949
response:
4050
body:
41-
string: "{\n \"id\": \"chatcmpl-AMTlCEj20ZcsgWKZt8EizFMDItWNf\",\n \"object\":
42-
\"chat.completion\",\n \"created\": 1729920978,\n \"model\": \"gpt-4o-mini-2024-07-18\",\n
43-
\ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\":
44-
\"assistant\",\n \"content\": \"This is a test. How can I assist you
45-
further?\",\n \"refusal\": null\n },\n \"logprobs\": null,\n
46-
\ \"finish_reason\": \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\":
47-
12,\n \"completion_tokens\": 12,\n \"total_tokens\": 24,\n \"prompt_tokens_details\":
48-
{\n \"cached_tokens\": 0\n },\n \"completion_tokens_details\":
49-
{\n \"reasoning_tokens\": 0\n }\n },\n \"service_tier\": \"default\",\n
50-
\ \"system_fingerprint\": \"fp_f59a81427f\"\n}\n"
51+
string: |-
52+
{
53+
"id": "chatcmpl-APfFNvBVQx43PNOIf1dWnEUT5u5fA",
54+
"object": "chat.completion",
55+
"created": 1730680117,
56+
"model": "gpt-4o-mini-2024-07-18",
57+
"choices": [
58+
{
59+
"index": 0,
60+
"message": {
61+
"role": "assistant",
62+
"content": "This is a test. How can I assist you further?",
63+
"refusal": null
64+
},
65+
"logprobs": null,
66+
"finish_reason": "stop"
67+
}
68+
],
69+
"usage": {
70+
"prompt_tokens": 12,
71+
"completion_tokens": 12,
72+
"total_tokens": 24,
73+
"prompt_tokens_details": {
74+
"cached_tokens": 0
75+
},
76+
"completion_tokens_details": {
77+
"reasoning_tokens": 0
78+
}
79+
},
80+
"service_tier": "default",
81+
"system_fingerprint": "fp_0ba0d124f1"
82+
}
5183
headers:
5284
CF-Cache-Status:
5385
- DYNAMIC
5486
CF-RAY:
55-
- 8d881682197c7571-SEA
87+
- 8dd07c2d0a5a9f98-SIN
5688
Connection:
5789
- keep-alive
5890
Content-Type:
5991
- application/json
6092
Date:
61-
- Sat, 26 Oct 2024 05:36:18 GMT
93+
- Mon, 04 Nov 2024 00:28:37 GMT
6294
Server:
6395
- cloudflare
6496
Set-Cookie: test_set_cookie
@@ -74,25 +106,25 @@ interactions:
74106
- '697'
75107
openai-organization: test_organization
76108
openai-processing-ms:
77-
- '275'
109+
- '228'
78110
openai-version:
79111
- '2020-10-01'
80112
strict-transport-security:
81113
- max-age=31536000; includeSubDomains; preload
82114
x-ratelimit-limit-requests:
83-
- '200'
115+
- '10000'
84116
x-ratelimit-limit-tokens:
85-
- '60000'
117+
- '200000'
86118
x-ratelimit-remaining-requests:
87-
- '195'
119+
- '9998'
88120
x-ratelimit-remaining-tokens:
89-
- '59944'
121+
- '199943'
90122
x-ratelimit-reset-requests:
91-
- 32m17.492s
123+
- 13.724s
92124
x-ratelimit-reset-tokens:
93-
- 56ms
125+
- 16ms
94126
x-request-id:
95-
- req_181075e8f861d6685fe1ae5d4bfc9b25
127+
- req_0ded46a4535c24c36ef58363b7538421
96128
status:
97129
code: 200
98130
message: OK

0 commit comments

Comments
 (0)