aws-otel-java-instrumentation
aws-otel-java-instrumentation copied to clipboard
Add Bedrock contract tests.
A rebased version of https://github.com/aws-observability/aws-otel-java-instrumentation/pull/848
The PR is a follow up on bedrock service support PR: https://github.com/aws-observability/aws-otel-python-instrumentation/pull/209
We add contract tests for following Bedrock services that covers all resource attributes we newly support:
- Bedrock API:
GetGuardrail - BedrockAgent APIs:
GetAgent,GetDataSource,GetKnowledgeBase - BedrockRuntime API:
InvokeModel - BedrockAgentRuntime API:
InvokeAgent
Upgrade botocore and boto3 to the latest version 1.34.143 so that to support Bedrock services API calls.
Upgrade localstack/localstack image to the latest version 3.5.0 so resolve the SQS API call issue using localstack/localstack:2.0.1 with new version of boto3: https://github.com/localstack/localstack/issues/9610
Contract test limitation: The contract tests in current repo is using LocalStackContainer to serve AWS SDK service calls. But it doesn’t has bedrock related service support (This is the full service list it support.). In this case, no matter which bedrock API we call in contract test, the response will always be 4XX.
As a workaround, we inject inject_200_success and inject_500_error directly into the API call to make sure we receive http response with expected status code and attributes.
_assert_semantic_conventions_span_attributes function change:
In _assert_semantic_conventions_span_attributes function it is checking the input service equals to rpc.service, however, we pass the input service with "remote_service", where there is mismatch for example for Bedrock Agent Runtime: we have
rpc_service="Bedrock Agent Runtime", remote_service="AWS::Bedrock".
Thus we change to use rpc_service if it is provided by:
kwargs.get("rpc_service") if "rpc_service" in kwargs else kwargs.get("remote_service").split("::")[-1],
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.