opentelemetry-instrumentation-openai 0.15.8__py3-none-any.whl → 0.15.9__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/__init__.py +4 -1
- opentelemetry/instrumentation/openai/shared/__init__.py +4 -5
- opentelemetry/instrumentation/openai/shared/config.py +1 -0
- opentelemetry/instrumentation/openai/utils.py +6 -0
- opentelemetry/instrumentation/openai/version.py +1 -1
- {opentelemetry_instrumentation_openai-0.15.8.dist-info → opentelemetry_instrumentation_openai-0.15.9.dist-info}/METADATA +1 -1
- {opentelemetry_instrumentation_openai-0.15.8.dist-info → opentelemetry_instrumentation_openai-0.15.9.dist-info}/RECORD +9 -9
- {opentelemetry_instrumentation_openai-0.15.8.dist-info → opentelemetry_instrumentation_openai-0.15.9.dist-info}/WHEEL +0 -0
- {opentelemetry_instrumentation_openai-0.15.8.dist-info → opentelemetry_instrumentation_openai-0.15.9.dist-info}/entry_points.txt +0 -0
|
@@ -13,9 +13,12 @@ _instruments = ("openai >= 0.27.0",)
|
|
|
13
13
|
class OpenAIInstrumentor(BaseInstrumentor):
|
|
14
14
|
"""An instrumentor for OpenAI's client library."""
|
|
15
15
|
|
|
16
|
-
def __init__(
|
|
16
|
+
def __init__(
|
|
17
|
+
self, enrich_assistant: bool = False, enrich_token_usage: bool = False
|
|
18
|
+
):
|
|
17
19
|
super().__init__()
|
|
18
20
|
Config.enrich_assistant = enrich_assistant
|
|
21
|
+
Config.enrich_token_usage = enrich_token_usage
|
|
19
22
|
|
|
20
23
|
def instrumentation_dependencies(self) -> Collection[str]:
|
|
21
24
|
return _instruments
|
|
@@ -9,7 +9,10 @@ from importlib.metadata import version
|
|
|
9
9
|
from opentelemetry import context as context_api
|
|
10
10
|
|
|
11
11
|
from opentelemetry.semconv.ai import SpanAttributes
|
|
12
|
-
from opentelemetry.instrumentation.openai.utils import
|
|
12
|
+
from opentelemetry.instrumentation.openai.utils import (
|
|
13
|
+
is_openai_v1,
|
|
14
|
+
should_record_stream_token_usage,
|
|
15
|
+
)
|
|
13
16
|
|
|
14
17
|
OPENAI_API_VERSION = "openai.api_version"
|
|
15
18
|
OPENAI_API_BASE = "openai.api_base"
|
|
@@ -238,10 +241,6 @@ def model_as_dict(model):
|
|
|
238
241
|
return model
|
|
239
242
|
|
|
240
243
|
|
|
241
|
-
def should_record_stream_token_usage():
|
|
242
|
-
return (os.getenv("TRACELOOP_STREAM_TOKEN_USAGE") or "false").lower() == "true"
|
|
243
|
-
|
|
244
|
-
|
|
245
244
|
def get_token_count_from_string(string: str, model_name: str):
|
|
246
245
|
if not should_record_stream_token_usage():
|
|
247
246
|
return None
|
|
@@ -2,6 +2,8 @@ from importlib.metadata import version
|
|
|
2
2
|
from contextlib import asynccontextmanager
|
|
3
3
|
import os
|
|
4
4
|
|
|
5
|
+
from opentelemetry.instrumentation.openai.shared.config import Config
|
|
6
|
+
|
|
5
7
|
|
|
6
8
|
def is_openai_v1():
|
|
7
9
|
return version("openai") >= "1.0.0"
|
|
@@ -11,6 +13,10 @@ def is_metrics_enabled() -> bool:
|
|
|
11
13
|
return (os.getenv("TRACELOOP_METRICS_ENABLED") or "true").lower() == "true"
|
|
12
14
|
|
|
13
15
|
|
|
16
|
+
def should_record_stream_token_usage():
|
|
17
|
+
return Config.enrich_token_usage
|
|
18
|
+
|
|
19
|
+
|
|
14
20
|
def _with_image_gen_metric_wrapper(func):
|
|
15
21
|
def _with_metric(duration_histogram, exception_counter):
|
|
16
22
|
def wrapper(wrapped, instance, args, kwargs):
|
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "0.15.
|
|
1
|
+
__version__ = "0.15.9"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: opentelemetry-instrumentation-openai
|
|
3
|
-
Version: 0.15.
|
|
3
|
+
Version: 0.15.9
|
|
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,17 +1,17 @@
|
|
|
1
|
-
opentelemetry/instrumentation/openai/__init__.py,sha256=
|
|
2
|
-
opentelemetry/instrumentation/openai/shared/__init__.py,sha256=
|
|
1
|
+
opentelemetry/instrumentation/openai/__init__.py,sha256=VSQyN0asXvBQD4jAm46xnHRHjKU74Zqzo1UimaC0ws8,1245
|
|
2
|
+
opentelemetry/instrumentation/openai/shared/__init__.py,sha256=o0QGgSMDC8aE2PmV3z6AMdH4nP-SiUQ0w3aKhXXBvzg,8320
|
|
3
3
|
opentelemetry/instrumentation/openai/shared/chat_wrappers.py,sha256=LvoZNowNh7KhTWgvp528Ma-Wrd506yPYLveBvgeT8p4,13697
|
|
4
4
|
opentelemetry/instrumentation/openai/shared/completion_wrappers.py,sha256=xg9qNqijT5ZJOk509l9Q7kVHLwo88DUH-Uv4tzSkeOQ,7045
|
|
5
|
-
opentelemetry/instrumentation/openai/shared/config.py,sha256=
|
|
5
|
+
opentelemetry/instrumentation/openai/shared/config.py,sha256=hd2oUeASejh5bEKot76pvQNONpWKsrw2S3iH3j3XsVs,74
|
|
6
6
|
opentelemetry/instrumentation/openai/shared/embeddings_wrappers.py,sha256=zr7qsH5bpnRMahErgstpphLI-XPN8y7Pxh2_39Oo4Ds,5573
|
|
7
7
|
opentelemetry/instrumentation/openai/shared/image_gen_wrappers.py,sha256=SnmhXnnO5pyc0x9wvbYb1S_OVM4TYr7qeJPZbs3YxJg,1899
|
|
8
|
-
opentelemetry/instrumentation/openai/utils.py,sha256=
|
|
8
|
+
opentelemetry/instrumentation/openai/utils.py,sha256=l63pdGpBMEy8oLPlt4QrNL35qYW4nf5ItNsZYYZG7jU,2554
|
|
9
9
|
opentelemetry/instrumentation/openai/v0/__init__.py,sha256=lwKZYa7zhYoEKw9hNQAQ68MZnaYA4-nqJrDUcm2I4ZA,5554
|
|
10
10
|
opentelemetry/instrumentation/openai/v1/__init__.py,sha256=A9X07leoMeErJaBGMMXAD5nYPc6xaUj2Ng5mriOsZ8Q,8162
|
|
11
11
|
opentelemetry/instrumentation/openai/v1/assistant_wrappers.py,sha256=T6Vtdp1fAZdcYjGiTMZwkn4F4DgsltD4p4xLEFW-GhI,5874
|
|
12
12
|
opentelemetry/instrumentation/openai/v1/event_handler_wrapper.py,sha256=SAzYoun2yyOloofyOWtxpm8E2M9TL3Nm8TgKdNyXHuY,2779
|
|
13
|
-
opentelemetry/instrumentation/openai/version.py,sha256=
|
|
14
|
-
opentelemetry_instrumentation_openai-0.15.
|
|
15
|
-
opentelemetry_instrumentation_openai-0.15.
|
|
16
|
-
opentelemetry_instrumentation_openai-0.15.
|
|
17
|
-
opentelemetry_instrumentation_openai-0.15.
|
|
13
|
+
opentelemetry/instrumentation/openai/version.py,sha256=k-GJzgMV-c2ATHbR4wgw0IKwlkANiQ4VvTZ6xMxt9UA,23
|
|
14
|
+
opentelemetry_instrumentation_openai-0.15.9.dist-info/METADATA,sha256=2J11zzA3JcGnRIIPvic3wWuBQJYIxHq1lIy7bMG7A8Q,2218
|
|
15
|
+
opentelemetry_instrumentation_openai-0.15.9.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
16
|
+
opentelemetry_instrumentation_openai-0.15.9.dist-info/entry_points.txt,sha256=vTBfiX5yXji5YHikuJHEOoBZ1TFdPQ1EI4ctd2pZSeE,93
|
|
17
|
+
opentelemetry_instrumentation_openai-0.15.9.dist-info/RECORD,,
|
|
File without changes
|