telemetry-dev-openai 0.1.8__tar.gz → 0.2.0__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: telemetry-dev-openai
3
- Version: 0.1.8
3
+ Version: 0.2.0
4
4
  Summary: OpenAI integration for telemetry.dev Python SDK
5
5
  Keywords: telemetry,opentelemetry,openai,llm,genai,tracing
6
6
  Author: telemetry.dev
@@ -43,6 +43,10 @@ import telemetry_dev
43
43
  telemetry_dev.init(service_name="my-service")
44
44
  ```
45
45
 
46
+ Versions of `telemetry-dev` before 0.3.0 sent data to `https://ingest.telemetry.dev` by default.
47
+ That hostname reaches the same service and stays supported: if a firewall allows only it, set
48
+ `TELEMETRY_DEV_BASE_URL` to it.
49
+
46
50
  ## Per-client wrapping
47
51
 
48
52
  ```py
@@ -99,7 +103,7 @@ Chat completion streams are traced. Requests are sent unchanged by default, so t
99
103
 
100
104
  Streamed chat output and finish reasons use separate budgets of up to 48 KiB and 1,000 items; the configured `max_attribute_length` does not shrink these retention bounds; the core applies it to the exported attribute after the mask runs, with its `...[truncated]` marker, without setting `telemetry.dev.capture.truncated`. When present, `gen_ai.output.messages` contains bounded partial output. If output and/or finish-reason capture is incomplete, including when a choice ends without `finish_reason`, `telemetry.dev.capture.truncated` is `true`. With a mask configured, incomplete output is omitted because the mask cannot inspect the complete value. When output capture is disabled or omitted, response IDs and models, finish reasons, usage, timing, and errors may still be recorded.
101
105
 
102
- Capture flags do not gate stop sequences, caller-supplied metadata or raw attributes, or exception messages and stack traces; redact those separately when needed.
106
+ Capture flags do not gate stop sequences or caller-supplied metadata or raw attributes; redact those separately when needed. Exception messages and stack traces are recorded only when both `capture_input` and `capture_output` are on, and pass through `mask`. Older `telemetry-dev` versions record them regardless of capture flags.
103
107
 
104
108
  ```py
105
109
  client = wrap_openai(OpenAI(), inject_stream_usage=True)
@@ -20,6 +20,10 @@ import telemetry_dev
20
20
  telemetry_dev.init(service_name="my-service")
21
21
  ```
22
22
 
23
+ Versions of `telemetry-dev` before 0.3.0 sent data to `https://ingest.telemetry.dev` by default.
24
+ That hostname reaches the same service and stays supported: if a firewall allows only it, set
25
+ `TELEMETRY_DEV_BASE_URL` to it.
26
+
23
27
  ## Per-client wrapping
24
28
 
25
29
  ```py
@@ -76,7 +80,7 @@ Chat completion streams are traced. Requests are sent unchanged by default, so t
76
80
 
77
81
  Streamed chat output and finish reasons use separate budgets of up to 48 KiB and 1,000 items; the configured `max_attribute_length` does not shrink these retention bounds; the core applies it to the exported attribute after the mask runs, with its `...[truncated]` marker, without setting `telemetry.dev.capture.truncated`. When present, `gen_ai.output.messages` contains bounded partial output. If output and/or finish-reason capture is incomplete, including when a choice ends without `finish_reason`, `telemetry.dev.capture.truncated` is `true`. With a mask configured, incomplete output is omitted because the mask cannot inspect the complete value. When output capture is disabled or omitted, response IDs and models, finish reasons, usage, timing, and errors may still be recorded.
78
82
 
79
- Capture flags do not gate stop sequences, caller-supplied metadata or raw attributes, or exception messages and stack traces; redact those separately when needed.
83
+ Capture flags do not gate stop sequences or caller-supplied metadata or raw attributes; redact those separately when needed. Exception messages and stack traces are recorded only when both `capture_input` and `capture_output` are on, and pass through `mask`. Older `telemetry-dev` versions record them regardless of capture flags.
80
84
 
81
85
  ```py
82
86
  client = wrap_openai(OpenAI(), inject_stream_usage=True)
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "telemetry-dev-openai"
3
- version = "0.1.8"
3
+ version = "0.2.0"
4
4
  description = "OpenAI integration for telemetry.dev Python SDK"
5
5
  readme = "README.md"
6
6
  license = "MIT"
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "telemetry-dev-openai"
3
- version = "0.1.8"
3
+ version = "0.2.0"
4
4
  description = "OpenAI integration for telemetry.dev Python SDK"
5
5
  readme = "README.md"
6
6
  license = "MIT"
@@ -20,7 +20,7 @@ from openai.resources.embeddings import AsyncEmbeddings, Embeddings
20
20
  from openai.resources.images import AsyncImages, Images
21
21
  from openai.resources.responses.responses import AsyncResponses, Responses
22
22
 
23
- __version__ = "0.1.8"
23
+ __version__ = "0.2.0"
24
24
 
25
25
  ProviderResolver = Callable[[object | None], str]
26
26
  RequestMapper = Callable[[Mapping[str, Any]], tuple[str, dict[str, Any]]]
@@ -524,11 +524,8 @@ def _media_response(response: Any) -> dict[str, Any]:
524
524
  }
525
525
 
526
526
 
527
- def _text_media_response(response: Any, *, capture_output: bool | None = None) -> dict[str, Any]:
527
+ def _text_media_response(response: Any, *, capture_output: bool = False) -> dict[str, Any]:
528
528
  fields = _media_response(response)
529
- if capture_output is None:
530
- client = telemetry_dev.get_client()
531
- capture_output = client is not None and client.capture_output
532
529
  if capture_output:
533
530
  text = _string(_field(response, "text"))
534
531
  if text is not None:
@@ -1458,26 +1455,12 @@ def _hook_response_close(inner: Any, finish: Callable[[], None]) -> None:
1458
1455
 
1459
1456
 
1460
1457
  def _chat_span_capture_policy(handle: telemetry_dev.SpanHandle) -> tuple[bool, bool]:
1461
- compatible = cast(Any, handle)
1462
- client = getattr(compatible, "_client", None)
1463
- state = getattr(compatible, "_state", None)
1464
- capture_output = getattr(compatible, "capture_output", None)
1465
- if not isinstance(capture_output, bool):
1466
- capture_output = getattr(state, "capture_output", None)
1467
- if not isinstance(capture_output, bool):
1468
- capture_output = getattr(client, "capture_output", False)
1469
- capture_masked = getattr(compatible, "capture_masked", None)
1470
- if not isinstance(capture_masked, bool):
1471
- capture_masked = getattr(client, "mask", _OMIT) is not None if client is not None else True
1472
- return capture_output, capture_masked
1458
+ return handle.capture_output, handle.capture_masked
1473
1459
 
1474
1460
 
1475
1461
  def _chat_span_reporter(
1476
1462
  handle: telemetry_dev.SpanHandle,
1477
1463
  ) -> Callable[[BaseException], None]:
1478
- compatible = cast(Any, handle)
1479
- reporter = getattr(compatible, "report_error", None)
1480
- client = getattr(compatible, "_client", None)
1481
1464
  reported = False
1482
1465
 
1483
1466
  def report(cause: BaseException) -> None:
@@ -1486,12 +1469,7 @@ def _chat_span_reporter(
1486
1469
  return
1487
1470
  reported = True
1488
1471
  try:
1489
- if callable(reporter):
1490
- reporter(cause)
1491
- return
1492
- client_report = getattr(client, "report", None)
1493
- if callable(client_report):
1494
- client_report("provider instrumentation failed", cause)
1472
+ handle.report_error(cause)
1495
1473
  except Exception:
1496
1474
  return
1497
1475
 
@@ -1668,9 +1646,7 @@ class _InstrumentedStream:
1668
1646
  self._unterminated_choices,
1669
1647
  )
1670
1648
  if update["has_output"]:
1671
- record_output_chunk = getattr(self._handle, "record_output_chunk", None)
1672
- if callable(record_output_chunk):
1673
- record_output_chunk(received_at * 1000)
1649
+ self._handle.record_output_chunk(received_at * 1000)
1674
1650
  if not self._saw_first:
1675
1651
  self._saw_first = True
1676
1652
  self._handle.update(
@@ -1838,9 +1814,7 @@ class _InstrumentedAsyncStream:
1838
1814
  self._unterminated_choices,
1839
1815
  )
1840
1816
  if update["has_output"]:
1841
- record_output_chunk = getattr(self._handle, "record_output_chunk", None)
1842
- if callable(record_output_chunk):
1843
- record_output_chunk(received_at * 1000)
1817
+ self._handle.record_output_chunk(received_at * 1000)
1844
1818
  if not self._saw_first:
1845
1819
  self._saw_first = True
1846
1820
  self._handle.update(
@@ -1955,9 +1929,7 @@ class _InstrumentedResponsesStream:
1955
1929
 
1956
1930
  def _record(self, event: Any, received_at: float) -> None:
1957
1931
  if _response_event_has_output(event):
1958
- record_output_chunk = getattr(self._handle, "record_output_chunk", None)
1959
- if callable(record_output_chunk):
1960
- record_output_chunk(received_at * 1000)
1932
+ self._handle.record_output_chunk(received_at * 1000)
1961
1933
  if not self._saw_first:
1962
1934
  self._saw_first = True
1963
1935
  self._handle.update(
@@ -2108,9 +2080,7 @@ class _InstrumentedAsyncResponsesStream:
2108
2080
 
2109
2081
  def _record(self, event: Any, received_at: float) -> None:
2110
2082
  if _response_event_has_output(event):
2111
- record_output_chunk = getattr(self._handle, "record_output_chunk", None)
2112
- if callable(record_output_chunk):
2113
- record_output_chunk(received_at * 1000)
2083
+ self._handle.record_output_chunk(received_at * 1000)
2114
2084
  if not self._saw_first:
2115
2085
  self._saw_first = True
2116
2086
  self._handle.update(