telemetry-dev-bedrock 0.2.3__tar.gz → 0.2.5__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-bedrock
3
- Version: 0.2.3
3
+ Version: 0.2.5
4
4
  Summary: AWS Bedrock integration for telemetry.dev Python SDK
5
5
  Keywords: telemetry,opentelemetry,bedrock,aws,boto3,genai,tracing
6
6
  Author: telemetry.dev
@@ -77,7 +77,7 @@ telemetry_dev.init(
77
77
  bedrock = wrap_bedrock(boto3.client("bedrock-runtime", region_name="us-east-1"))
78
78
 
79
79
  bedrock.converse(
80
- modelId="anthropic.claude-3-5-haiku-20241022-v1:0",
80
+ modelId="global.anthropic.claude-haiku-5-5",
81
81
  messages=[{"role": "user", "content": [{"text": "Hello"}]}],
82
82
  )
83
83
 
@@ -169,7 +169,7 @@ InvokeModel captures provider-native JSON bodies verbatim. A body whose content
169
169
  - Requests are never modified.
170
170
  - Streams end spans exactly once. Exhaustion records full output and finish reason; early `break`, `close()`, `GeneratorExit`, or stream errors record partial output and set `telemetry.dev.capture.truncated`.
171
171
  - Event-stream reconstruction and streamed `InvokeModel` bodies are kept up to 16 MiB, and all streams in flight share the `max_stream_bytes` bound of the core (64 MiB by default). These bounds need a `telemetry-dev` core with `max_stream_bytes`; with an older core, each stream keeps up to 64 KiB and 1,024 items. `InvokeModel` bodies and `Rerank` inputs and results are retained up to 16 MiB each; a body over that bound records no output and sets `telemetry.dev.capture.truncated`. The configured `max_attribute_length` does not shrink these retention bounds; the core applies it to the exported attribute after the mask runs.
172
- - A stream cut at its retention bound, closed early, or failed sets `telemetry.dev.capture.truncated`. An event that fails to map is reported to `on_error`; only the first such failure of a stream is reported. A failure before the event's output is kept also sets the attribute, and no later text or content is kept; so does an `InvokeModel` stream chunk that is not UTF-8 or not JSON (a blank chunk holds no output and is skipped). Agent text is decoded across chunks, so a character split between two chunks is kept whole; Agent text that is not UTF-8, or a stream that ends inside a character, loses that text like a failed event and is reported; an Agent `returnControl` that arrives later still replaces the text output whole, also with a mask configured. A failure in the event's usage, metrics, or Agent trace summaries loses only that metadata and does not set the attribute. A failure while Agent trace content is captured (`capture_agent_trace`) loses that trace and sets the attribute, but later text is still kept, also with a mask configured. A stream whose output fails to map when it ends records no output and sets the attribute. An `InvokeModel` body that is closed before it is fully read, whose read fails, or that fails to map (for example, a body that is not UTF-8 or not JSON) records no output and sets the attribute too; a mapping failure is reported to `on_error`. With a mask configured, incomplete reconstructed output is omitted because the mask cannot inspect the complete value. Agent trace events share the bound, but dropping them only sets the attribute; Agent text is omitted only when a text chunk was dropped or failed to map, or the stream was closed early or failed. A normally exhausted Agent stream that returned control keeps its complete `returnControl` output even if earlier text or trace metadata passed the bound; an early close or failure still omits the output when a mask is configured.
172
+ - A stream cut at its retention bound, closed early, or failed sets `telemetry.dev.capture.truncated`. An event that fails to map, or a failure while the time to first chunk or an output-chunk timestamp is recorded, is reported to `on_error`; only the first such failure of a stream is reported. A failure before the event's output is kept also sets the attribute, and no later text or content is kept; so does an `InvokeModel` stream chunk that is not UTF-8 or not JSON (a blank chunk holds no output and is skipped). Agent text is decoded across chunks, so a character split between two chunks is kept whole; Agent text that is not UTF-8, or a stream that ends inside a character, loses that text like a failed event and is reported; an Agent `returnControl` that arrives later still replaces the text output whole, also with a mask configured. A failure in the event's usage, metrics, or Agent trace summaries loses only that metadata and does not set the attribute, and so does a timing failure. A failure while Agent trace content is captured (`capture_agent_trace`) loses that trace and sets the attribute, but later text is still kept, also with a mask configured. A stream whose output fails to map when it ends records no output and sets the attribute. An `InvokeModel` body that is closed before it is fully read, whose read fails, or that fails to map (for example, a body that is not UTF-8 or not JSON) records no output and sets the attribute too; a mapping failure is reported to `on_error`. With a mask configured, incomplete reconstructed output is omitted because the mask cannot inspect the complete value. Agent trace events share the bound, but dropping them only sets the attribute; Agent text is omitted only when a text chunk was dropped or failed to map, or the stream was closed early or failed. A normally exhausted Agent stream that returned control keeps its complete `returnControl` output even if earlier text or trace metadata passed the bound; an early close or failure still omits the output when a mask is configured.
173
173
  - boto3 has no async client. `aiobotocore` is a separate package and is out of scope.
174
174
 
175
175
  ## Coverage gaps
@@ -54,7 +54,7 @@ telemetry_dev.init(
54
54
  bedrock = wrap_bedrock(boto3.client("bedrock-runtime", region_name="us-east-1"))
55
55
 
56
56
  bedrock.converse(
57
- modelId="anthropic.claude-3-5-haiku-20241022-v1:0",
57
+ modelId="global.anthropic.claude-haiku-5-5",
58
58
  messages=[{"role": "user", "content": [{"text": "Hello"}]}],
59
59
  )
60
60
 
@@ -146,7 +146,7 @@ InvokeModel captures provider-native JSON bodies verbatim. A body whose content
146
146
  - Requests are never modified.
147
147
  - Streams end spans exactly once. Exhaustion records full output and finish reason; early `break`, `close()`, `GeneratorExit`, or stream errors record partial output and set `telemetry.dev.capture.truncated`.
148
148
  - Event-stream reconstruction and streamed `InvokeModel` bodies are kept up to 16 MiB, and all streams in flight share the `max_stream_bytes` bound of the core (64 MiB by default). These bounds need a `telemetry-dev` core with `max_stream_bytes`; with an older core, each stream keeps up to 64 KiB and 1,024 items. `InvokeModel` bodies and `Rerank` inputs and results are retained up to 16 MiB each; a body over that bound records no output and sets `telemetry.dev.capture.truncated`. The configured `max_attribute_length` does not shrink these retention bounds; the core applies it to the exported attribute after the mask runs.
149
- - A stream cut at its retention bound, closed early, or failed sets `telemetry.dev.capture.truncated`. An event that fails to map is reported to `on_error`; only the first such failure of a stream is reported. A failure before the event's output is kept also sets the attribute, and no later text or content is kept; so does an `InvokeModel` stream chunk that is not UTF-8 or not JSON (a blank chunk holds no output and is skipped). Agent text is decoded across chunks, so a character split between two chunks is kept whole; Agent text that is not UTF-8, or a stream that ends inside a character, loses that text like a failed event and is reported; an Agent `returnControl` that arrives later still replaces the text output whole, also with a mask configured. A failure in the event's usage, metrics, or Agent trace summaries loses only that metadata and does not set the attribute. A failure while Agent trace content is captured (`capture_agent_trace`) loses that trace and sets the attribute, but later text is still kept, also with a mask configured. A stream whose output fails to map when it ends records no output and sets the attribute. An `InvokeModel` body that is closed before it is fully read, whose read fails, or that fails to map (for example, a body that is not UTF-8 or not JSON) records no output and sets the attribute too; a mapping failure is reported to `on_error`. With a mask configured, incomplete reconstructed output is omitted because the mask cannot inspect the complete value. Agent trace events share the bound, but dropping them only sets the attribute; Agent text is omitted only when a text chunk was dropped or failed to map, or the stream was closed early or failed. A normally exhausted Agent stream that returned control keeps its complete `returnControl` output even if earlier text or trace metadata passed the bound; an early close or failure still omits the output when a mask is configured.
149
+ - A stream cut at its retention bound, closed early, or failed sets `telemetry.dev.capture.truncated`. An event that fails to map, or a failure while the time to first chunk or an output-chunk timestamp is recorded, is reported to `on_error`; only the first such failure of a stream is reported. A failure before the event's output is kept also sets the attribute, and no later text or content is kept; so does an `InvokeModel` stream chunk that is not UTF-8 or not JSON (a blank chunk holds no output and is skipped). Agent text is decoded across chunks, so a character split between two chunks is kept whole; Agent text that is not UTF-8, or a stream that ends inside a character, loses that text like a failed event and is reported; an Agent `returnControl` that arrives later still replaces the text output whole, also with a mask configured. A failure in the event's usage, metrics, or Agent trace summaries loses only that metadata and does not set the attribute, and so does a timing failure. A failure while Agent trace content is captured (`capture_agent_trace`) loses that trace and sets the attribute, but later text is still kept, also with a mask configured. A stream whose output fails to map when it ends records no output and sets the attribute. An `InvokeModel` body that is closed before it is fully read, whose read fails, or that fails to map (for example, a body that is not UTF-8 or not JSON) records no output and sets the attribute too; a mapping failure is reported to `on_error`. With a mask configured, incomplete reconstructed output is omitted because the mask cannot inspect the complete value. Agent trace events share the bound, but dropping them only sets the attribute; Agent text is omitted only when a text chunk was dropped or failed to map, or the stream was closed early or failed. A normally exhausted Agent stream that returned control keeps its complete `returnControl` output even if earlier text or trace metadata passed the bound; an early close or failure still omits the output when a mask is configured.
150
150
  - boto3 has no async client. `aiobotocore` is a separate package and is out of scope.
151
151
 
152
152
  ## Coverage gaps
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "telemetry-dev-bedrock"
3
- version = "0.2.3"
3
+ version = "0.2.5"
4
4
  description = "AWS Bedrock 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-bedrock"
3
- version = "0.2.3"
3
+ version = "0.2.5"
4
4
  description = "AWS Bedrock integration for telemetry.dev Python SDK"
5
5
  readme = "README.md"
6
6
  license = "MIT"
@@ -2,6 +2,6 @@ from __future__ import annotations
2
2
 
3
3
  from ._instrument import instrument_bedrock, uninstrument_bedrock, wrap_bedrock
4
4
 
5
- __version__ = "0.2.3"
5
+ __version__ = "0.2.5"
6
6
 
7
7
  __all__ = ["__version__", "instrument_bedrock", "uninstrument_bedrock", "wrap_bedrock"]
@@ -181,8 +181,8 @@ def _call_with_span(
181
181
  if fields.keys() == {"time_to_first_chunk_ms"}:
182
182
  try:
183
183
  handle.update(**fields)
184
- except Exception:
185
- pass
184
+ except Exception as exc:
185
+ report_error(exc)
186
186
  return
187
187
  end(**merge_fields(base_fields, fields))
188
188
 
@@ -19,7 +19,6 @@ from ._messages import normalize_content_block
19
19
 
20
20
  # The core applies max_attribute_length after the mask.
21
21
  _CAPTURE_TRUNCATED_ATTRIBUTE = "telemetry.dev.capture.truncated"
22
- _OMIT = object()
23
22
 
24
23
 
25
24
  def stream_capture_budget() -> telemetry_dev.CaptureBudget:
@@ -106,14 +105,6 @@ class _DeltaBuffer:
106
105
  raise
107
106
 
108
107
 
109
- def capture_masked(handle: Any) -> bool:
110
- masked = getattr(handle, "capture_masked", None)
111
- if isinstance(masked, bool):
112
- return masked
113
- client = getattr(handle, "_client", None)
114
- return getattr(client, "mask", _OMIT) is not None if client is not None else True
115
-
116
-
117
108
  def mark_capture_incomplete(fields: dict[str, Any], mask_output: bool) -> dict[str, Any]:
118
109
  marked = merge_fields(fields, {"attributes": {_CAPTURE_TRUNCATED_ATTRIBUTE: True}})
119
110
  if mask_output:
@@ -580,7 +571,7 @@ class AgentStreamState(StreamState):
580
571
  # Metadata bypasses the capture flags and the mask, so trace content is filtered here,
581
572
  # and a mask that cannot see it withholds it.
582
573
  client = telemetry_dev.get_client()
583
- masked = client is None or getattr(client, "mask", _OMIT) is not None
574
+ masked = client is None or client.mask is not None
584
575
  self.trace_capture = {
585
576
  "input": client is not None and client.capture_input and not masked,
586
577
  "output": client is not None and client.capture_output and not masked,
@@ -792,7 +783,7 @@ class InstrumentedEventStream:
792
783
  state: StreamState,
793
784
  finish: Callable[[dict[str, Any]], None],
794
785
  started_at: float,
795
- handle: Any,
786
+ handle: telemetry_dev.SpanHandle,
796
787
  report_error: Callable[[BaseException], None],
797
788
  ) -> None:
798
789
  self._stream = stream
@@ -803,7 +794,7 @@ class InstrumentedEventStream:
803
794
  self._ended = False
804
795
  self._first = False
805
796
  self._track_output_chunks = isinstance(state, ConverseStreamState | InvokeModelStreamState)
806
- self._mask_output_when_incomplete = capture_masked(handle)
797
+ self._mask_output_when_incomplete = handle.capture_masked
807
798
  self._report_error = report_error
808
799
  state.report_error = self._report_error
809
800
 
@@ -832,19 +823,18 @@ class InstrumentedEventStream:
832
823
  self._state.text_rejected = True
833
824
  state_has_output = None
834
825
  if self._track_output_chunks:
835
- # Chunk timing must not reach the caller. When feed() failed, the fallback
836
- # reads the event again and can fail the same way, which feed() reported.
826
+ # Chunk timing must not reach the caller. A failure loses only the timing;
827
+ # when feed() already failed, the fallback can fail the same way and the
828
+ # reporter drops the repeat.
837
829
  try:
838
830
  if (
839
831
  state_has_output
840
832
  if state_has_output is not None
841
833
  else _event_has_output(event)
842
834
  ):
843
- record_output_chunk = getattr(self._handle, "record_output_chunk", None)
844
- if callable(record_output_chunk):
845
- record_output_chunk(received_at * 1000)
846
- except Exception:
847
- pass
835
+ self._handle.record_output_chunk(received_at * 1000)
836
+ except Exception as exc:
837
+ self._report_error(exc)
848
838
  yield event
849
839
  completed = True
850
840
  except GeneratorExit: