Skip to content

Commit fbb013e

Browse files
committed
Make it explicit we are handling only the converse operation
1 parent 2c73701 commit fbb013e

File tree

1 file changed

+11
-0
lines changed
  • instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/extensions

1 file changed

+11
-0
lines changed

instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/extensions/bedrock.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,14 @@ class _BedrockRuntimeExtension(_AwsSdkExtension):
5353
Amazon Bedrock Runtime</a>.
5454
"""
5555

56+
_HANDLED_OPERATIONS = {"Converse"}
57+
5658
def extract_attributes(self, attributes: _AttributeMapT):
5759
attributes[GEN_AI_SYSTEM] = GenAiSystemValues.AWS_BEDROCK.value
5860

61+
if self._call_context.operation not in self._HANDLED_OPERATIONS:
62+
return
63+
5964
model_id = self._call_context.params.get(_MODEL_ID_KEY)
6065
if model_id:
6166
attributes[GEN_AI_REQUEST_MODEL] = model_id
@@ -97,6 +102,9 @@ def _set_if_not_none(attributes, key, value):
97102
attributes[key] = value
98103

99104
def before_service_call(self, span: Span):
105+
if self._call_context.operation not in self._HANDLED_OPERATIONS:
106+
return
107+
100108
if not span.is_recording():
101109
return
102110

@@ -107,6 +115,9 @@ def before_service_call(self, span: Span):
107115
span.update_name(f"{operation_name} {request_model}")
108116

109117
def on_success(self, span: Span, result: dict[str, Any]):
118+
if self._call_context.operation not in self._HANDLED_OPERATIONS:
119+
return
120+
110121
model_id = self._call_context.params.get(_MODEL_ID_KEY)
111122

112123
if not model_id:

0 commit comments

Comments
 (0)