opentelemetry-instrumentation-openai 0.38.2__tar.gz → 0.38.3__tar.gz
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-0.38.2 → opentelemetry_instrumentation_openai-0.38.3}/PKG-INFO +1 -1
- {opentelemetry_instrumentation_openai-0.38.2 → opentelemetry_instrumentation_openai-0.38.3}/opentelemetry/instrumentation/openai/shared/__init__.py +10 -4
- {opentelemetry_instrumentation_openai-0.38.2 → opentelemetry_instrumentation_openai-0.38.3}/opentelemetry/instrumentation/openai/shared/chat_wrappers.py +6 -0
- {opentelemetry_instrumentation_openai-0.38.2 → opentelemetry_instrumentation_openai-0.38.3}/opentelemetry/instrumentation/openai/shared/completion_wrappers.py +12 -2
- {opentelemetry_instrumentation_openai-0.38.2 → opentelemetry_instrumentation_openai-0.38.3}/opentelemetry/instrumentation/openai/shared/embeddings_wrappers.py +7 -0
- opentelemetry_instrumentation_openai-0.38.3/opentelemetry/instrumentation/openai/version.py +1 -0
- {opentelemetry_instrumentation_openai-0.38.2 → opentelemetry_instrumentation_openai-0.38.3}/pyproject.toml +1 -1
- opentelemetry_instrumentation_openai-0.38.2/opentelemetry/instrumentation/openai/version.py +0 -1
- {opentelemetry_instrumentation_openai-0.38.2 → opentelemetry_instrumentation_openai-0.38.3}/README.md +0 -0
- {opentelemetry_instrumentation_openai-0.38.2 → opentelemetry_instrumentation_openai-0.38.3}/opentelemetry/instrumentation/openai/__init__.py +0 -0
- {opentelemetry_instrumentation_openai-0.38.2 → opentelemetry_instrumentation_openai-0.38.3}/opentelemetry/instrumentation/openai/shared/config.py +0 -0
- {opentelemetry_instrumentation_openai-0.38.2 → opentelemetry_instrumentation_openai-0.38.3}/opentelemetry/instrumentation/openai/shared/image_gen_wrappers.py +0 -0
- {opentelemetry_instrumentation_openai-0.38.2 → opentelemetry_instrumentation_openai-0.38.3}/opentelemetry/instrumentation/openai/utils.py +0 -0
- {opentelemetry_instrumentation_openai-0.38.2 → opentelemetry_instrumentation_openai-0.38.3}/opentelemetry/instrumentation/openai/v0/__init__.py +0 -0
- {opentelemetry_instrumentation_openai-0.38.2 → opentelemetry_instrumentation_openai-0.38.3}/opentelemetry/instrumentation/openai/v1/__init__.py +0 -0
- {opentelemetry_instrumentation_openai-0.38.2 → opentelemetry_instrumentation_openai-0.38.3}/opentelemetry/instrumentation/openai/v1/assistant_wrappers.py +0 -0
- {opentelemetry_instrumentation_openai-0.38.2 → opentelemetry_instrumentation_openai-0.38.3}/opentelemetry/instrumentation/openai/v1/event_handler_wrapper.py +0 -0
|
@@ -304,7 +304,13 @@ def metric_shared_attributes(
|
|
|
304
304
|
|
|
305
305
|
|
|
306
306
|
def propagate_trace_context(span, kwargs):
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.38.3"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.38.2"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|