opentelemetry-instrumentation-openai 0.25.0__tar.gz → 0.25.1__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.25.0 → opentelemetry_instrumentation_openai-0.25.1}/PKG-INFO +1 -1
- {opentelemetry_instrumentation_openai-0.25.0 → opentelemetry_instrumentation_openai-0.25.1}/opentelemetry/instrumentation/openai/__init__.py +3 -1
- {opentelemetry_instrumentation_openai-0.25.0 → opentelemetry_instrumentation_openai-0.25.1}/opentelemetry/instrumentation/openai/shared/__init__.py +5 -1
- {opentelemetry_instrumentation_openai-0.25.0 → opentelemetry_instrumentation_openai-0.25.1}/opentelemetry/instrumentation/openai/shared/chat_wrappers.py +6 -3
- {opentelemetry_instrumentation_openai-0.25.0 → opentelemetry_instrumentation_openai-0.25.1}/opentelemetry/instrumentation/openai/shared/config.py +4 -0
- {opentelemetry_instrumentation_openai-0.25.0 → opentelemetry_instrumentation_openai-0.25.1}/opentelemetry/instrumentation/openai/shared/embeddings_wrappers.py +2 -2
- {opentelemetry_instrumentation_openai-0.25.0 → opentelemetry_instrumentation_openai-0.25.1}/opentelemetry/instrumentation/openai/shared/image_gen_wrappers.py +2 -2
- opentelemetry_instrumentation_openai-0.25.1/opentelemetry/instrumentation/openai/version.py +1 -0
- {opentelemetry_instrumentation_openai-0.25.0 → opentelemetry_instrumentation_openai-0.25.1}/pyproject.toml +1 -1
- opentelemetry_instrumentation_openai-0.25.0/opentelemetry/instrumentation/openai/version.py +0 -1
- {opentelemetry_instrumentation_openai-0.25.0 → opentelemetry_instrumentation_openai-0.25.1}/README.md +0 -0
- {opentelemetry_instrumentation_openai-0.25.0 → opentelemetry_instrumentation_openai-0.25.1}/opentelemetry/instrumentation/openai/shared/completion_wrappers.py +0 -0
- {opentelemetry_instrumentation_openai-0.25.0 → opentelemetry_instrumentation_openai-0.25.1}/opentelemetry/instrumentation/openai/utils.py +0 -0
- {opentelemetry_instrumentation_openai-0.25.0 → opentelemetry_instrumentation_openai-0.25.1}/opentelemetry/instrumentation/openai/v0/__init__.py +0 -0
- {opentelemetry_instrumentation_openai-0.25.0 → opentelemetry_instrumentation_openai-0.25.1}/opentelemetry/instrumentation/openai/v1/__init__.py +0 -0
- {opentelemetry_instrumentation_openai-0.25.0 → opentelemetry_instrumentation_openai-0.25.1}/opentelemetry/instrumentation/openai/v1/assistant_wrappers.py +0 -0
- {opentelemetry_instrumentation_openai-0.25.0 → opentelemetry_instrumentation_openai-0.25.1}/opentelemetry/instrumentation/openai/v1/event_handler_wrapper.py +0 -0
{opentelemetry_instrumentation_openai-0.25.0 → opentelemetry_instrumentation_openai-0.25.1}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: opentelemetry-instrumentation-openai
|
|
3
|
-
Version: 0.25.
|
|
3
|
+
Version: 0.25.1
|
|
4
4
|
Summary: OpenTelemetry OpenAI instrumentation
|
|
5
5
|
Home-page: https://github.com/traceloop/openllmetry/tree/main/packages/opentelemetry-instrumentation-openai
|
|
6
6
|
License: Apache-2.0
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import Collection
|
|
1
|
+
from typing import Callable, Collection
|
|
2
2
|
|
|
3
3
|
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
|
|
4
4
|
|
|
@@ -18,11 +18,13 @@ class OpenAIInstrumentor(BaseInstrumentor):
|
|
|
18
18
|
enrich_assistant: bool = False,
|
|
19
19
|
enrich_token_usage: bool = False,
|
|
20
20
|
exception_logger=None,
|
|
21
|
+
get_common_metrics_attributes: Callable[[], dict] = lambda: {},
|
|
21
22
|
):
|
|
22
23
|
super().__init__()
|
|
23
24
|
Config.enrich_assistant = enrich_assistant
|
|
24
25
|
Config.enrich_token_usage = enrich_token_usage
|
|
25
26
|
Config.exception_logger = exception_logger
|
|
27
|
+
Config.get_common_metrics_attributes = get_common_metrics_attributes
|
|
26
28
|
|
|
27
29
|
def instrumentation_dependencies(self) -> Collection[str]:
|
|
28
30
|
return _instruments
|
|
@@ -8,6 +8,7 @@ from importlib.metadata import version
|
|
|
8
8
|
|
|
9
9
|
from opentelemetry import context as context_api
|
|
10
10
|
|
|
11
|
+
from opentelemetry.instrumentation.openai.shared.config import Config
|
|
11
12
|
from opentelemetry.semconv.ai import SpanAttributes
|
|
12
13
|
from opentelemetry.instrumentation.openai.utils import (
|
|
13
14
|
dont_throw,
|
|
@@ -256,10 +257,13 @@ def _token_type(token_type: str):
|
|
|
256
257
|
return None
|
|
257
258
|
|
|
258
259
|
|
|
259
|
-
def
|
|
260
|
+
def metric_shared_attributes(
|
|
260
261
|
response_model: str, operation: str, server_address: str, is_streaming: bool = False
|
|
261
262
|
):
|
|
263
|
+
attributes = Config.get_common_metrics_attributes()
|
|
264
|
+
|
|
262
265
|
return {
|
|
266
|
+
**attributes,
|
|
263
267
|
SpanAttributes.LLM_SYSTEM: "openai",
|
|
264
268
|
SpanAttributes.LLM_RESPONSE_MODEL: response_model,
|
|
265
269
|
"gen_ai.operation.name": operation,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import json
|
|
2
2
|
import logging
|
|
3
3
|
import time
|
|
4
|
+
from opentelemetry.instrumentation.openai.shared.config import Config
|
|
4
5
|
from wrapt import ObjectProxy
|
|
5
6
|
|
|
6
7
|
|
|
@@ -18,7 +19,7 @@ from opentelemetry.instrumentation.openai.utils import (
|
|
|
18
19
|
dont_throw,
|
|
19
20
|
)
|
|
20
21
|
from opentelemetry.instrumentation.openai.shared import (
|
|
21
|
-
|
|
22
|
+
metric_shared_attributes,
|
|
22
23
|
_set_client_attributes,
|
|
23
24
|
_set_request_attributes,
|
|
24
25
|
_set_span_attribute,
|
|
@@ -172,7 +173,9 @@ async def achat_wrapper(
|
|
|
172
173
|
end_time = time.time()
|
|
173
174
|
duration = end_time - start_time if "start_time" in locals() else 0
|
|
174
175
|
|
|
176
|
+
common_attributes = Config.get_common_metrics_attributes()
|
|
175
177
|
attributes = {
|
|
178
|
+
**common_attributes,
|
|
176
179
|
"error.type": e.__class__.__name__,
|
|
177
180
|
}
|
|
178
181
|
|
|
@@ -277,7 +280,7 @@ def _handle_response(
|
|
|
277
280
|
def _set_chat_metrics(
|
|
278
281
|
instance, token_counter, choice_counter, duration_histogram, response_dict, duration
|
|
279
282
|
):
|
|
280
|
-
shared_attributes =
|
|
283
|
+
shared_attributes = metric_shared_attributes(
|
|
281
284
|
response_model=response_dict.get("model") or None,
|
|
282
285
|
operation="chat",
|
|
283
286
|
server_address=_get_openai_base_url(instance),
|
|
@@ -554,7 +557,7 @@ class ChatStream(ObjectProxy):
|
|
|
554
557
|
_accumulate_stream_items(item, self._complete_response)
|
|
555
558
|
|
|
556
559
|
def _shared_attributes(self):
|
|
557
|
-
return
|
|
560
|
+
return metric_shared_attributes(
|
|
558
561
|
response_model=self._complete_response.get("model")
|
|
559
562
|
or self._request_kwargs.get("model")
|
|
560
563
|
or None,
|
|
@@ -16,7 +16,7 @@ from opentelemetry.instrumentation.openai.utils import (
|
|
|
16
16
|
_with_embeddings_telemetry_wrapper,
|
|
17
17
|
)
|
|
18
18
|
from opentelemetry.instrumentation.openai.shared import (
|
|
19
|
-
|
|
19
|
+
metric_shared_attributes,
|
|
20
20
|
_set_client_attributes,
|
|
21
21
|
_set_request_attributes,
|
|
22
22
|
_set_span_attribute,
|
|
@@ -198,7 +198,7 @@ def _set_embeddings_metrics(
|
|
|
198
198
|
response_dict,
|
|
199
199
|
duration,
|
|
200
200
|
):
|
|
201
|
-
shared_attributes =
|
|
201
|
+
shared_attributes = metric_shared_attributes(
|
|
202
202
|
response_model=response_dict.get("model") or None,
|
|
203
203
|
operation="embeddings",
|
|
204
204
|
server_address=_get_openai_base_url(instance),
|
|
@@ -4,7 +4,7 @@ from opentelemetry import context as context_api
|
|
|
4
4
|
from opentelemetry.instrumentation.openai import is_openai_v1
|
|
5
5
|
from opentelemetry.instrumentation.openai.shared import (
|
|
6
6
|
_get_openai_base_url,
|
|
7
|
-
|
|
7
|
+
metric_shared_attributes,
|
|
8
8
|
model_as_dict,
|
|
9
9
|
)
|
|
10
10
|
from opentelemetry.instrumentation.openai.utils import (
|
|
@@ -55,7 +55,7 @@ def image_gen_metrics_wrapper(
|
|
|
55
55
|
response_dict = response
|
|
56
56
|
|
|
57
57
|
# not provide response.model in ImagesResponse response, use model in request kwargs
|
|
58
|
-
shared_attributes =
|
|
58
|
+
shared_attributes = metric_shared_attributes(
|
|
59
59
|
response_model=kwargs.get("model") or None,
|
|
60
60
|
operation="image_gen",
|
|
61
61
|
server_address=_get_openai_base_url(instance),
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.25.1"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.25.0"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|