opentelemetry-instrumentation-botocore 0.52b1__py3-none-any.whl → 0.53b0__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.
@@ -28,7 +28,7 @@ Usage
28
28
  .. code:: python
29
29
 
30
30
  from opentelemetry.instrumentation.botocore import BotocoreInstrumentor
31
- import botocore
31
+ import botocore.session
32
32
 
33
33
 
34
34
  # Instrument Botocore
@@ -39,7 +39,7 @@ Usage
39
39
  session.set_credentials(
40
40
  access_key="access-key", secret_key="secret-key"
41
41
  )
42
- ec2 = self.session.create_client("ec2", region_name="us-west-2")
42
+ ec2 = session.create_client("ec2", region_name="us-west-2")
43
43
  ec2.describe_instances()
44
44
 
45
45
  API
@@ -58,13 +58,15 @@ for example:
58
58
  .. code: python
59
59
 
60
60
  from opentelemetry.instrumentation.botocore import BotocoreInstrumentor
61
- import botocore
61
+ import botocore.session
62
62
 
63
63
  def request_hook(span, service_name, operation_name, api_params):
64
64
  # request hook logic
65
+ pass
65
66
 
66
67
  def response_hook(span, service_name, operation_name, result):
67
68
  # response hook logic
69
+ pass
68
70
 
69
71
  # Instrument Botocore with hooks
70
72
  BotocoreInstrumentor().instrument(request_hook=request_hook, response_hook=response_hook)
@@ -74,40 +76,8 @@ for example:
74
76
  session.set_credentials(
75
77
  access_key="access-key", secret_key="secret-key"
76
78
  )
77
- ec2 = self.session.create_client("ec2", region_name="us-west-2")
79
+ ec2 = session.create_client("ec2", region_name="us-west-2")
78
80
  ec2.describe_instances()
79
-
80
- Extensions
81
- ----------
82
-
83
- The instrumentation supports creating extensions for AWS services for enriching what is collected. We have extensions
84
- for the following AWS services:
85
-
86
- - Bedrock Runtime
87
- - DynamoDB
88
- - Lambda
89
- - SNS
90
- - SQS
91
-
92
- Bedrock Runtime
93
- ***************
94
-
95
- This extension implements the GenAI semantic conventions for the following API calls:
96
-
97
- - Converse
98
- - ConverseStream
99
- - InvokeModel
100
- - InvokeModelWithResponseStream
101
-
102
- For the Converse and ConverseStream APIs tracing, events and metrics are implemented.
103
-
104
- For the InvokeModel and InvokeModelWithResponseStream APIs tracing, events and metrics implemented only for a subset of
105
- the available models, namely:
106
- - Amazon Titan models
107
- - Amazon Nova models
108
- - Anthropic Claude
109
-
110
- There is no support for tool calls with Amazon Models for the InvokeModel and InvokeModelWithResponseStream APIs.
111
81
  """
112
82
 
113
83
  import logging
@@ -216,7 +216,6 @@ class InvokeModelWithResponseStreamWrapper(ObjectProxy):
216
216
 
217
217
  def _process_amazon_nova_chunk(self, chunk):
218
218
  # pylint: disable=too-many-branches
219
- # TODO: handle tool calls!
220
219
  if "messageStart" in chunk:
221
220
  # {'messageStart': {'role': 'assistant'}}
222
221
  if chunk["messageStart"].get("role") == "assistant":
@@ -224,17 +223,40 @@ class InvokeModelWithResponseStreamWrapper(ObjectProxy):
224
223
  self._message = {"role": "assistant", "content": []}
225
224
  return
226
225
 
226
+ if "contentBlockStart" in chunk:
227
+ # {'contentBlockStart': {'start': {'toolUse': {'toolUseId': 'id', 'name': 'name'}}, 'contentBlockIndex': 31}}
228
+ if self._record_message:
229
+ self._message["content"].append(self._content_block)
230
+
231
+ start = chunk["contentBlockStart"].get("start", {})
232
+ if "toolUse" in start:
233
+ self._content_block = start
234
+ else:
235
+ self._content_block = {}
236
+ return
237
+
227
238
  if "contentBlockDelta" in chunk:
228
239
  # {'contentBlockDelta': {'delta': {'text': "Hello"}, 'contentBlockIndex': 0}}
240
+ # {'contentBlockDelta': {'delta': {'toolUse': {'input': '{"location":"San Francisco"}'}}, 'contentBlockIndex': 31}}
229
241
  if self._record_message:
230
242
  delta = chunk["contentBlockDelta"].get("delta", {})
231
243
  if "text" in delta:
232
244
  self._content_block.setdefault("text", "")
233
245
  self._content_block["text"] += delta["text"]
246
+ elif "toolUse" in delta:
247
+ self._content_block.setdefault("toolUse", {})
248
+ self._content_block["toolUse"]["input"] = json.loads(
249
+ delta["toolUse"]["input"]
250
+ )
234
251
  return
235
252
 
236
253
  if "contentBlockStop" in chunk:
237
254
  # {'contentBlockStop': {'contentBlockIndex': 0}}
255
+ if self._record_message:
256
+ # create a new content block only for tools
257
+ if "toolUse" in self._content_block:
258
+ self._message["content"].append(self._content_block)
259
+ self._content_block = {}
238
260
  return
239
261
 
240
262
  if "messageStop" in chunk:
@@ -12,4 +12,4 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- __version__ = "0.52b1"
15
+ __version__ = "0.53b0"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: opentelemetry-instrumentation-botocore
3
- Version: 0.52b1
3
+ Version: 0.53b0
4
4
  Summary: OpenTelemetry Botocore instrumentation
5
5
  Project-URL: Homepage, https://github.com/open-telemetry/opentelemetry-python-contrib/tree/main/instrumentation/opentelemetry-instrumentation-botocore
6
6
  Project-URL: Repository, https://github.com/open-telemetry/opentelemetry-python-contrib
@@ -20,9 +20,9 @@ Classifier: Programming Language :: Python :: 3.12
20
20
  Classifier: Programming Language :: Python :: 3.13
21
21
  Requires-Python: >=3.8
22
22
  Requires-Dist: opentelemetry-api~=1.30
23
- Requires-Dist: opentelemetry-instrumentation==0.52b1
23
+ Requires-Dist: opentelemetry-instrumentation==0.53b0
24
24
  Requires-Dist: opentelemetry-propagator-aws-xray~=1.0
25
- Requires-Dist: opentelemetry-semantic-conventions==0.52b1
25
+ Requires-Dist: opentelemetry-semantic-conventions==0.53b0
26
26
  Provides-Extra: instruments
27
27
  Requires-Dist: botocore~=1.0; extra == 'instruments'
28
28
  Description-Content-Type: text/x-rst
@@ -37,6 +37,44 @@ OpenTelemetry Botocore Tracing
37
37
 
38
38
  This library allows tracing requests made by the Botocore library.
39
39
 
40
+ Extensions
41
+ ----------
42
+
43
+ The instrumentation supports creating extensions for AWS services for enriching what is collected. We have extensions
44
+ for the following AWS services:
45
+
46
+ - Bedrock Runtime
47
+ - DynamoDB
48
+ - Lambda
49
+ - SNS
50
+ - SQS
51
+
52
+ Bedrock Runtime
53
+ ***************
54
+
55
+ This extension implements the GenAI semantic conventions for the following API calls:
56
+
57
+ - Converse
58
+ - ConverseStream
59
+ - InvokeModel
60
+ - InvokeModelWithResponseStream
61
+
62
+ For the Converse and ConverseStream APIs tracing, events and metrics are implemented.
63
+
64
+ For the InvokeModel and InvokeModelWithResponseStream APIs tracing, events and metrics implemented only for a subset of
65
+ the available models, namely:
66
+
67
+ - Amazon Titan models
68
+ - Amazon Nova models
69
+ - Anthropic Claude
70
+
71
+ Tool calls with InvokeModel and InvokeModelWithResponseStream APIs are supported with:
72
+
73
+ - Amazon Nova models
74
+ - Anthropic Claude 3+
75
+
76
+ If you don't have an application using Bedrock APIs yet, try our `zero-code examples <examples/bedrock-runtime/zero-code>`_.
77
+
40
78
  Installation
41
79
  ------------
42
80
 
@@ -1,18 +1,18 @@
1
- opentelemetry/instrumentation/botocore/__init__.py,sha256=3kgHjhP9dxM3ZsjPCYtLtZKwOwL5Rc16UM3K837qHmg,15368
1
+ opentelemetry/instrumentation/botocore/__init__.py,sha256=vqJdCimwcLKwvGfXvsT-UW4PD5R0MLb4xPAB1Xdk_Lo,14565
2
2
  opentelemetry/instrumentation/botocore/environment_variables.py,sha256=c1lrIEj5wwxZwLd5ppJsfGADBfQLnb_HuxXDLv7ul6s,114
3
3
  opentelemetry/instrumentation/botocore/package.py,sha256=6xvfRpU_C3wlSO6pto7MhGtkPoCHDEiRO_Fh4DiC_50,622
4
- opentelemetry/instrumentation/botocore/version.py,sha256=baY9XBULpMqGtC6b52xBndx8f8B0qgZQnvEAOxvK-bs,608
4
+ opentelemetry/instrumentation/botocore/version.py,sha256=YINz8iltPDXGMAPN-XzoMRWHV-bhEWau0Rniz-pK9c0,608
5
5
  opentelemetry/instrumentation/botocore/extensions/__init__.py,sha256=IqMWsCI0HL8gvL8-0Svn9Rp7dz2HKMcIuhRRM0twmCU,1857
6
6
  opentelemetry/instrumentation/botocore/extensions/_messaging.py,sha256=ca2Uwyb1vxWu5qUkKTlfn9KJFN6k8HOTrrBYvwX4WzA,1636
7
7
  opentelemetry/instrumentation/botocore/extensions/bedrock.py,sha256=fF_SdRGZzTyGDprlffh84bMVQhq3AZMcMAZAUTj1SDA,27814
8
- opentelemetry/instrumentation/botocore/extensions/bedrock_utils.py,sha256=KMYlLigPaHxQq8nLQ0L0FHFEpwuVpYKIP9VugyKcysE,19430
8
+ opentelemetry/instrumentation/botocore/extensions/bedrock_utils.py,sha256=vR_INPz0UeT_ShajwZdLbXcys6mOmXSHwOxP3gR139I,20555
9
9
  opentelemetry/instrumentation/botocore/extensions/dynamodb.py,sha256=cmTzHnLCO731v8L5wN-rPRyVgQHmRvH3tuG5wrFhqyA,13745
10
10
  opentelemetry/instrumentation/botocore/extensions/lmbd.py,sha256=mqPbgwDFy3XYg-pLo6A6eNu0iKSGa2-tPLwroJDuavY,4253
11
11
  opentelemetry/instrumentation/botocore/extensions/sns.py,sha256=MfppfL91tAbAjp6CIiqvYIuXQRq-PeIYbB1ZKWO5kW4,5334
12
12
  opentelemetry/instrumentation/botocore/extensions/sqs.py,sha256=9_LjlzQ0Sg92hgaL8P31cbpq_C71qCTucjj0SX1Ct5o,2916
13
13
  opentelemetry/instrumentation/botocore/extensions/types.py,sha256=jCIJXt0Zvdn2qVwX6bLUaCLgBPy6XyJ-nYEwurxAZo8,6681
14
- opentelemetry_instrumentation_botocore-0.52b1.dist-info/METADATA,sha256=FAGsr0h-an9gy7r3X6vxZAKmkmC3W1-hfuFZ4kPU6q4,2122
15
- opentelemetry_instrumentation_botocore-0.52b1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
16
- opentelemetry_instrumentation_botocore-0.52b1.dist-info/entry_points.txt,sha256=v5hzQbZMJ61JuhBNq5jHYAapvv3C_486h9CTqxlkUTM,100
17
- opentelemetry_instrumentation_botocore-0.52b1.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
18
- opentelemetry_instrumentation_botocore-0.52b1.dist-info/RECORD,,
14
+ opentelemetry_instrumentation_botocore-0.53b0.dist-info/METADATA,sha256=zvCs12ew7IQoEPdMNJH_Uz4G8D8KCuCcJfDvf7X_s1s,3101
15
+ opentelemetry_instrumentation_botocore-0.53b0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
16
+ opentelemetry_instrumentation_botocore-0.53b0.dist-info/entry_points.txt,sha256=v5hzQbZMJ61JuhBNq5jHYAapvv3C_486h9CTqxlkUTM,100
17
+ opentelemetry_instrumentation_botocore-0.53b0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
18
+ opentelemetry_instrumentation_botocore-0.53b0.dist-info/RECORD,,