opentelemetry-instrumentation-openai 0.38.1__py3-none-any.whl → 0.38.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of opentelemetry-instrumentation-openai might be problematic. Click here for more details.
- opentelemetry/instrumentation/openai/shared/__init__.py +20 -7
- opentelemetry/instrumentation/openai/shared/chat_wrappers.py +6 -0
- opentelemetry/instrumentation/openai/shared/completion_wrappers.py +12 -2
- opentelemetry/instrumentation/openai/shared/embeddings_wrappers.py +7 -0
- opentelemetry/instrumentation/openai/version.py +1 -1
- {opentelemetry_instrumentation_openai-0.38.1.dist-info → opentelemetry_instrumentation_openai-0.38.3.dist-info}/METADATA +1 -1
- {opentelemetry_instrumentation_openai-0.38.1.dist-info → opentelemetry_instrumentation_openai-0.38.3.dist-info}/RECORD +9 -9
- {opentelemetry_instrumentation_openai-0.38.1.dist-info → opentelemetry_instrumentation_openai-0.38.3.dist-info}/WHEEL +0 -0
- {opentelemetry_instrumentation_openai-0.38.1.dist-info → opentelemetry_instrumentation_openai-0.38.3.dist-info}/entry_points.txt +0 -0
|
@@ -11,7 +11,9 @@ from opentelemetry.trace.propagation import set_span_in_context
|
|
|
11
11
|
from opentelemetry.trace.propagation.tracecontext import TraceContextTextMapPropagator
|
|
12
12
|
|
|
13
13
|
from opentelemetry.instrumentation.openai.shared.config import Config
|
|
14
|
-
from opentelemetry.semconv._incubating.attributes.gen_ai_attributes import
|
|
14
|
+
from opentelemetry.semconv._incubating.attributes.gen_ai_attributes import (
|
|
15
|
+
GEN_AI_RESPONSE_ID,
|
|
16
|
+
)
|
|
15
17
|
from opentelemetry.semconv_ai import SpanAttributes
|
|
16
18
|
from opentelemetry.instrumentation.openai.utils import (
|
|
17
19
|
dont_throw,
|
|
@@ -38,8 +40,13 @@ def should_send_prompts():
|
|
|
38
40
|
|
|
39
41
|
|
|
40
42
|
def _set_span_attribute(span, name, value):
|
|
41
|
-
if value is
|
|
42
|
-
|
|
43
|
+
if value is None or value == "":
|
|
44
|
+
return
|
|
45
|
+
|
|
46
|
+
if hasattr(openai, "NOT_GIVEN") and value == openai.NOT_GIVEN:
|
|
47
|
+
return
|
|
48
|
+
|
|
49
|
+
span.set_attribute(name, value)
|
|
43
50
|
|
|
44
51
|
|
|
45
52
|
def _set_client_attributes(span, instance):
|
|
@@ -297,7 +304,13 @@ def metric_shared_attributes(
|
|
|
297
304
|
|
|
298
305
|
|
|
299
306
|
def propagate_trace_context(span, kwargs):
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
307
|
+
if is_openai_v1():
|
|
308
|
+
extra_headers = kwargs.get("extra_headers", {})
|
|
309
|
+
ctx = set_span_in_context(span)
|
|
310
|
+
TraceContextTextMapPropagator().inject(extra_headers, context=ctx)
|
|
311
|
+
kwargs["extra_headers"] = extra_headers
|
|
312
|
+
else:
|
|
313
|
+
headers = kwargs.get("headers", {})
|
|
314
|
+
ctx = set_span_in_context(span)
|
|
315
|
+
TraceContextTextMapPropagator().inject(headers, context=ctx)
|
|
316
|
+
kwargs["headers"] = headers
|
|
@@ -98,6 +98,9 @@ def chat_wrapper(
|
|
|
98
98
|
if exception_counter:
|
|
99
99
|
exception_counter.add(1, attributes=attributes)
|
|
100
100
|
|
|
101
|
+
span.set_status(Status(StatusCode.ERROR, str(e)))
|
|
102
|
+
span.end()
|
|
103
|
+
|
|
101
104
|
raise e
|
|
102
105
|
|
|
103
106
|
if is_streaming_response(response):
|
|
@@ -190,6 +193,9 @@ async def achat_wrapper(
|
|
|
190
193
|
if exception_counter:
|
|
191
194
|
exception_counter.add(1, attributes=attributes)
|
|
192
195
|
|
|
196
|
+
span.set_status(Status(StatusCode.ERROR, str(e)))
|
|
197
|
+
span.end()
|
|
198
|
+
|
|
193
199
|
raise e
|
|
194
200
|
|
|
195
201
|
if is_streaming_response(response):
|
|
@@ -53,7 +53,12 @@ def completion_wrapper(tracer, wrapped, instance, args, kwargs):
|
|
|
53
53
|
)
|
|
54
54
|
|
|
55
55
|
_handle_request(span, kwargs, instance)
|
|
56
|
-
|
|
56
|
+
try:
|
|
57
|
+
response = wrapped(*args, **kwargs)
|
|
58
|
+
except Exception as e:
|
|
59
|
+
span.set_status(Status(StatusCode.ERROR, str(e)))
|
|
60
|
+
span.end()
|
|
61
|
+
raise e
|
|
57
62
|
|
|
58
63
|
if is_streaming_response(response):
|
|
59
64
|
# span will be closed after the generator is done
|
|
@@ -79,7 +84,12 @@ async def acompletion_wrapper(tracer, wrapped, instance, args, kwargs):
|
|
|
79
84
|
)
|
|
80
85
|
|
|
81
86
|
_handle_request(span, kwargs, instance)
|
|
82
|
-
|
|
87
|
+
try:
|
|
88
|
+
response = await wrapped(*args, **kwargs)
|
|
89
|
+
except Exception as e:
|
|
90
|
+
span.set_status(Status(StatusCode.ERROR, str(e)))
|
|
91
|
+
span.end()
|
|
92
|
+
raise e
|
|
83
93
|
|
|
84
94
|
if is_streaming_response(response):
|
|
85
95
|
# span will be closed after the generator is done
|
|
@@ -34,6 +34,7 @@ from opentelemetry.instrumentation.openai.shared.config import Config
|
|
|
34
34
|
from opentelemetry.instrumentation.openai.utils import is_openai_v1
|
|
35
35
|
|
|
36
36
|
from opentelemetry.trace import SpanKind
|
|
37
|
+
from opentelemetry.trace import Status, StatusCode
|
|
37
38
|
|
|
38
39
|
SPAN_NAME = "openai.embeddings"
|
|
39
40
|
LLM_REQUEST_TYPE = LLMRequestTypeValues.EMBEDDING
|
|
@@ -83,6 +84,9 @@ def embeddings_wrapper(
|
|
|
83
84
|
if exception_counter:
|
|
84
85
|
exception_counter.add(1, attributes=attributes)
|
|
85
86
|
|
|
87
|
+
span.set_status(Status(StatusCode.ERROR, str(e)))
|
|
88
|
+
span.end()
|
|
89
|
+
|
|
86
90
|
raise e
|
|
87
91
|
|
|
88
92
|
duration = end_time - start_time
|
|
@@ -142,6 +146,9 @@ async def aembeddings_wrapper(
|
|
|
142
146
|
if exception_counter:
|
|
143
147
|
exception_counter.add(1, attributes=attributes)
|
|
144
148
|
|
|
149
|
+
span.set_status(Status(StatusCode.ERROR, str(e)))
|
|
150
|
+
span.end()
|
|
151
|
+
|
|
145
152
|
raise e
|
|
146
153
|
|
|
147
154
|
duration = end_time - start_time
|
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "0.38.
|
|
1
|
+
__version__ = "0.38.3"
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
opentelemetry/instrumentation/openai/__init__.py,sha256=g_RyqxN0DEaPegyaFfoZVskxnaPMGx6Yrc9wZvkx7r8,2086
|
|
2
|
-
opentelemetry/instrumentation/openai/shared/__init__.py,sha256=
|
|
3
|
-
opentelemetry/instrumentation/openai/shared/chat_wrappers.py,sha256=
|
|
4
|
-
opentelemetry/instrumentation/openai/shared/completion_wrappers.py,sha256=
|
|
2
|
+
opentelemetry/instrumentation/openai/shared/__init__.py,sha256=k_jTu-WIn6nRSHSUehEhnujzkYhLCWl9tm1Lm5qTG-8,9800
|
|
3
|
+
opentelemetry/instrumentation/openai/shared/chat_wrappers.py,sha256=5otROZDeMN1w6kCWQIr8S9fQd2fHf1s-7absMTpjNPg,28462
|
|
4
|
+
opentelemetry/instrumentation/openai/shared/completion_wrappers.py,sha256=PYQNUaW37pPunsBE8Fj-nbSlwSJ54RN80muf3hjoMTU,7367
|
|
5
5
|
opentelemetry/instrumentation/openai/shared/config.py,sha256=dCQviJ1a5cpFlrP0HcKgE7lpiXB98ssnumLy_CIMibQ,355
|
|
6
|
-
opentelemetry/instrumentation/openai/shared/embeddings_wrappers.py,sha256=
|
|
6
|
+
opentelemetry/instrumentation/openai/shared/embeddings_wrappers.py,sha256=8l_TA_ncJWJr7Pr-1TcQV9eKNfJgdmi-9kOd8eOIwZI,7486
|
|
7
7
|
opentelemetry/instrumentation/openai/shared/image_gen_wrappers.py,sha256=A4qdJIeJdA45SfiLaFj3Vo0Ndcqqfuew1BDsGdnJU3E,2122
|
|
8
8
|
opentelemetry/instrumentation/openai/utils.py,sha256=B085XRVvCjigZlRewFRwEFTG2hdx5gv5qVakVxgYaVo,4086
|
|
9
9
|
opentelemetry/instrumentation/openai/v0/__init__.py,sha256=02-bXv0aZbscMYO2W3jsHpjU521vkVK5RzdfSeGXBzg,5475
|
|
10
10
|
opentelemetry/instrumentation/openai/v1/__init__.py,sha256=B2Ut0X14KQS5in_0jLBMCvXQK73SqBy2rBFIDk5ZRkc,8688
|
|
11
11
|
opentelemetry/instrumentation/openai/v1/assistant_wrappers.py,sha256=08ZB03chvpzF-v2dtpHKCToJmm5ztYSwKhBq3pbpPlI,7191
|
|
12
12
|
opentelemetry/instrumentation/openai/v1/event_handler_wrapper.py,sha256=4HsnPwR450NA5w-KDgMfQjK8U4do_M-sMMPU4LjXyiQ,3444
|
|
13
|
-
opentelemetry/instrumentation/openai/version.py,sha256=
|
|
14
|
-
opentelemetry_instrumentation_openai-0.38.
|
|
15
|
-
opentelemetry_instrumentation_openai-0.38.
|
|
16
|
-
opentelemetry_instrumentation_openai-0.38.
|
|
17
|
-
opentelemetry_instrumentation_openai-0.38.
|
|
13
|
+
opentelemetry/instrumentation/openai/version.py,sha256=1FI0PeL2E5_ENJHZ0QMlPezeXvC8q7AETOrTnDrNxM8,23
|
|
14
|
+
opentelemetry_instrumentation_openai-0.38.3.dist-info/METADATA,sha256=thFhvWmeodBXAHyzun7RB1YYI5v8Vs1jQaRnEimvPsE,2186
|
|
15
|
+
opentelemetry_instrumentation_openai-0.38.3.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
|
|
16
|
+
opentelemetry_instrumentation_openai-0.38.3.dist-info/entry_points.txt,sha256=vTBfiX5yXji5YHikuJHEOoBZ1TFdPQ1EI4ctd2pZSeE,93
|
|
17
|
+
opentelemetry_instrumentation_openai-0.38.3.dist-info/RECORD,,
|
|
File without changes
|