Skip to content

Commit d04f786

Browse files
committed
fix: function signature updates for upstream patches
1 parent 6b6aaf7 commit d04f786

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

aws-opentelemetry-distro/src/amazon/opentelemetry/distro/patches/_bedrock_patches.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ def extract_attributes(self, attributes: _AttributeMapT):
192192
if request_param_value:
193193
attributes[attribute_key] = request_param_value
194194

195-
def on_success(self, span: Span, result: _BotoResultT):
195+
def on_success(self, span: Span, result: _BotoResultT, instrumentor_context=None):
196196
if self._operation_class is None:
197197
return
198198

@@ -220,6 +220,10 @@ def extract_attributes(self, attributes: _AttributeMapT):
220220
knowledge_base_id = self._call_context.params.get(_KNOWLEDGE_BASE_ID)
221221
if knowledge_base_id:
222222
attributes[AWS_BEDROCK_KNOWLEDGE_BASE_ID] = knowledge_base_id
223+
224+
def on_success(self, span: Span, result: _BotoResultT, instrumentor_context=None):
225+
# Currently no attributes to extract from the result
226+
pass
223227

224228

225229
class _BedrockExtension(_AwsSdkExtension):
@@ -229,7 +233,7 @@ class _BedrockExtension(_AwsSdkExtension):
229233
"""
230234

231235
# pylint: disable=no-self-use
232-
def on_success(self, span: Span, result: _BotoResultT):
236+
def on_success(self, span: Span, result: _BotoResultT, instrumentor_context=None):
233237
# _GUARDRAIL_ID can only be retrieved from the response, not from the request
234238
guardrail_id = result.get(_GUARDRAIL_ID)
235239
if guardrail_id:
@@ -333,7 +337,7 @@ def _set_if_not_none(attributes, key, value):
333337
attributes[key] = value
334338

335339
# pylint: disable=too-many-branches
336-
def on_success(self, span: Span, result: Dict[str, Any]):
340+
def on_success(self, span: Span, result: Dict[str, Any], instrumentor_context=None):
337341
model_id = self._call_context.params.get(_MODEL_ID)
338342

339343
if not model_id:

aws-opentelemetry-distro/src/amazon/opentelemetry/distro/patches/_botocore_patches.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ def patch_extract_attributes(self, attributes: _AttributeMapT):
7575

7676
old_on_success = _LambdaExtension.on_success
7777

78-
def patch_on_success(self, span: Span, result: _BotoResultT):
79-
old_on_success(self, span, result)
78+
def patch_on_success(self, span: Span, result: _BotoResultT, instrumentor_context=None):
79+
old_on_success(self, span, result, instrumentor_context)
8080
lambda_configuration = result.get("Configuration", {})
8181
function_arn = lambda_configuration.get("FunctionArn")
8282
if function_arn:
@@ -180,8 +180,8 @@ def patch_extract_attributes(self, attributes: _AttributeMapT):
180180

181181
old_on_success = _SqsExtension.on_success
182182

183-
def patch_on_success(self, span: Span, result: _BotoResultT):
184-
old_on_success(self, span, result)
183+
def patch_on_success(self, span: Span, result: _BotoResultT, instrumentor_context=None):
184+
old_on_success(self, span, result, instrumentor_context)
185185
queue_url = result.get("QueueUrl")
186186
if queue_url:
187187
span.set_attribute(AWS_SQS_QUEUE_URL, queue_url)
@@ -243,7 +243,7 @@ def extract_attributes(self, attributes: _AttributeMapT):
243243
attributes[AWS_SECRETSMANAGER_SECRET_ARN] = secret_id
244244

245245
# pylint: disable=no-self-use
246-
def on_success(self, span: Span, result: _BotoResultT):
246+
def on_success(self, span: Span, result: _BotoResultT, instrumentor_context=None):
247247
secret_arn = result.get("ARN")
248248
if secret_arn:
249249
span.set_attribute(AWS_SECRETSMANAGER_SECRET_ARN, secret_arn)

aws-opentelemetry-distro/tests/amazon/opentelemetry/distro/test_instrumentation_patch.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def _test_unpatched_botocore_instrumentation(self):
147147
)
148148

149149
# BedrockRuntime
150-
self.assertFalse("bedrock-runtime" in _KNOWN_EXTENSIONS, "Upstream has added a bedrock-runtime extension")
150+
self.assertTrue("bedrock-runtime" in _KNOWN_EXTENSIONS, "Upstream has added a bedrock-runtime extension")
151151

152152
# SecretsManager
153153
self.assertFalse("secretsmanager" in _KNOWN_EXTENSIONS, "Upstream has added a SecretsManager extension")
@@ -678,6 +678,7 @@ def _do_on_success(
678678
) -> Dict[str, str]:
679679
span_mock: Span = MagicMock()
680680
mock_call_context = MagicMock()
681+
mock_instrumentor_context = MagicMock()
681682
span_attributes: Dict[str, str] = {}
682683

683684
def set_side_effect(set_key, set_value):
@@ -692,6 +693,6 @@ def set_side_effect(set_key, set_value):
692693
mock_call_context.params = params
693694

694695
extension = _KNOWN_EXTENSIONS[service_name]()(mock_call_context)
695-
extension.on_success(span_mock, result)
696+
extension.on_success(span_mock, result, mock_instrumentor_context)
696697

697698
return span_attributes

0 commit comments

Comments
 (0)