opentelemetry-instrumentation-openai 0.27.0__py3-none-any.whl → 0.28.0__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.

@@ -33,10 +33,8 @@ def should_send_prompts():
33
33
 
34
34
 
35
35
  def _set_span_attribute(span, name, value):
36
- if value is not None:
37
- if value != "":
38
- span.set_attribute(name, value)
39
- return
36
+ if value is not None and value != "" and value != openai.NOT_GIVEN:
37
+ span.set_attribute(name, value)
40
38
 
41
39
 
42
40
  def _set_client_attributes(span, instance):
@@ -39,7 +39,7 @@ from opentelemetry.instrumentation.openai.shared import (
39
39
  from opentelemetry.trace import SpanKind, Tracer
40
40
  from opentelemetry.trace.status import Status, StatusCode
41
41
 
42
- from opentelemetry.instrumentation.openai.utils import is_openai_v1, is_azure_openai
42
+ from opentelemetry.instrumentation.openai.utils import is_openai_v1
43
43
 
44
44
  SPAN_NAME = "openai.chat"
45
45
  PROMPT_FILTER_KEY = "prompt_filter_results"
@@ -428,6 +428,7 @@ def _set_completions(span, choices):
428
428
  )
429
429
 
430
430
 
431
+ @dont_throw
431
432
  def _set_streaming_token_metrics(
432
433
  request_kwargs, complete_response, span, token_counter, shared_attributes
433
434
  ):
@@ -745,10 +746,9 @@ async def _abuild_from_streaming_response(
745
746
  "stream": True,
746
747
  }
747
748
 
748
- if not is_azure_openai(instance):
749
- _set_streaming_token_metrics(
750
- request_kwargs, complete_response, span, token_counter, shared_attributes
751
- )
749
+ _set_streaming_token_metrics(
750
+ request_kwargs, complete_response, span, token_counter, shared_attributes
751
+ )
752
752
 
753
753
  # choice metrics
754
754
  if choice_counter and complete_response.get("choices"):
@@ -209,6 +209,9 @@ def _set_embeddings_metrics(
209
209
  if usage and token_counter:
210
210
  for name, val in usage.items():
211
211
  if name in OPENAI_LLM_USAGE_TOKEN_TYPES:
212
+ if val is None:
213
+ logging.error(f"Received None value for {name} in usage")
214
+ continue
212
215
  attributes_with_token_type = {
213
216
  **shared_attributes,
214
217
  SpanAttributes.LLM_TOKEN_TYPE: _token_type(name),
@@ -1 +1 @@
1
- __version__ = "0.27.0"
1
+ __version__ = "0.28.0"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: opentelemetry-instrumentation-openai
3
- Version: 0.27.0
3
+ Version: 0.28.0
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
1
  opentelemetry/instrumentation/openai/__init__.py,sha256=w0gjgORccQ3EsMiK2dzZg6V7J3pa6PcAuDvy1oofQ5A,1503
2
- opentelemetry/instrumentation/openai/shared/__init__.py,sha256=S6QoxypTSF1dMg4gfS3A3M0TzU2HVz9D6J6CleUXI54,8832
3
- opentelemetry/instrumentation/openai/shared/chat_wrappers.py,sha256=HEe0-vsCS8mDI585b6-Vybzy2EOpQ-FDpAz7LvVMWmQ,26776
2
+ opentelemetry/instrumentation/openai/shared/__init__.py,sha256=HcS1Ar6WX9DPtlJuiPji3u7XV_SwYerTf5O32Kfe1FQ,8839
3
+ opentelemetry/instrumentation/openai/shared/chat_wrappers.py,sha256=J1s8DqJoSPpOZE__21Iq0QrhFPf3WhIeDqcoIaUPtPU,26721
4
4
  opentelemetry/instrumentation/openai/shared/completion_wrappers.py,sha256=DO4K0DU3xvCAmBMcp3pS3iDTKHLY6Pc_4Y7GnlnRo0g,6840
5
5
  opentelemetry/instrumentation/openai/shared/config.py,sha256=_4AkHau8C44uBc6-fNBl9EzCGPBuj9yDIngTuwSW6ZE,199
6
- opentelemetry/instrumentation/openai/shared/embeddings_wrappers.py,sha256=REcu_K8ogVIf8RR935w_UqS-ajGI0CNun73_P476i2o,6930
6
+ opentelemetry/instrumentation/openai/shared/embeddings_wrappers.py,sha256=YI0lFGulaE8N2F1hdTGHj52kHwUy6KQPIt7Lw9AWJHc,7069
7
7
  opentelemetry/instrumentation/openai/shared/image_gen_wrappers.py,sha256=A4qdJIeJdA45SfiLaFj3Vo0Ndcqqfuew1BDsGdnJU3E,2122
8
8
  opentelemetry/instrumentation/openai/utils.py,sha256=3ONjsia3xG4rRMOwjU91liOVpZxoRE39CxJ-C5HxIgQ,3464
9
9
  opentelemetry/instrumentation/openai/v0/__init__.py,sha256=02-bXv0aZbscMYO2W3jsHpjU521vkVK5RzdfSeGXBzg,5475
10
10
  opentelemetry/instrumentation/openai/v1/__init__.py,sha256=kqGsXkjyjIDNRfTSzJKjLdvvGUOViW2shZ73cM4PfS0,7693
11
11
  opentelemetry/instrumentation/openai/v1/assistant_wrappers.py,sha256=BMiZykQ3u2xrWpo2g3qZOxTJqy317JXRGO4zCVu4bZ8,6277
12
12
  opentelemetry/instrumentation/openai/v1/event_handler_wrapper.py,sha256=kXOuDAt7If23EhWpH2r6L0eUVFvVWQBYrWGu3qJNKR0,2779
13
- opentelemetry/instrumentation/openai/version.py,sha256=Hjsc9XQ3AkqXm-5cdlX-H8iKjURzi1FQeWNi2xx34Uo,23
14
- opentelemetry_instrumentation_openai-0.27.0.dist-info/METADATA,sha256=KVupDehy33exBIOWDQ4cPDlws4LJOCq8SbeRdIUJNhA,2255
15
- opentelemetry_instrumentation_openai-0.27.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
16
- opentelemetry_instrumentation_openai-0.27.0.dist-info/entry_points.txt,sha256=vTBfiX5yXji5YHikuJHEOoBZ1TFdPQ1EI4ctd2pZSeE,93
17
- opentelemetry_instrumentation_openai-0.27.0.dist-info/RECORD,,
13
+ opentelemetry/instrumentation/openai/version.py,sha256=MRQGtOXBhcDKeeNOL0LiB-cllo6kfd8_KGJOvaDp0XQ,23
14
+ opentelemetry_instrumentation_openai-0.28.0.dist-info/METADATA,sha256=2ZUsVk7hWnrgtJq4ITVYZbzUHgcQLjDzv1Tuh_rMCu0,2255
15
+ opentelemetry_instrumentation_openai-0.28.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
16
+ opentelemetry_instrumentation_openai-0.28.0.dist-info/entry_points.txt,sha256=vTBfiX5yXji5YHikuJHEOoBZ1TFdPQ1EI4ctd2pZSeE,93
17
+ opentelemetry_instrumentation_openai-0.28.0.dist-info/RECORD,,