Skip to content

Commit f7ecf32

Browse files
committed
Add server and port assertions for Bedrock API calls
1 parent 4820f06 commit f7ecf32

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

instrumentation/opentelemetry-instrumentation-botocore/tests/bedrock_utils.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
GEN_AI_CLIENT_OPERATION_DURATION,
4040
GEN_AI_CLIENT_TOKEN_USAGE,
4141
)
42+
from opentelemetry.semconv.trace import SpanAttributes
4243

4344

4445
# pylint: disable=too-many-branches, too-many-locals, too-many-statements
@@ -221,6 +222,8 @@ def assert_all_attributes(
221222
request_temperature: int | None = None,
222223
request_max_tokens: int | None = None,
223224
request_stop_sequences: tuple[str] | None = None,
225+
server_address: str = "bedrock-runtime.us-east-1.amazonaws.com",
226+
server_port: int = 443,
224227
):
225228
assert span.name == f"{operation_name} {request_model}"
226229
assert (
@@ -235,6 +238,9 @@ def assert_all_attributes(
235238
request_model == span.attributes[GenAIAttributes.GEN_AI_REQUEST_MODEL]
236239
)
237240

241+
assert server_address == span.attributes[SpanAttributes.SERVER_ADDRESS]
242+
assert server_port == span.attributes[SpanAttributes.SERVER_PORT]
243+
238244
assert_equal_or_not_present(
239245
input_tokens, GenAIAttributes.GEN_AI_USAGE_INPUT_TOKENS, span
240246
)

0 commit comments

Comments
 (0)