generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 28
feat: Add botocore instrumentation extension for Bedrock AgentCore services #490
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wangzlei
reviewed
Oct 15, 2025
aws-opentelemetry-distro/src/amazon/opentelemetry/distro/patches/_bedrock_agentcore_patches.py
Show resolved
Hide resolved
wangzlei
approved these changes
Oct 15, 2025
mxiamxia
reviewed
Oct 15, 2025
aws-opentelemetry-distro/src/amazon/opentelemetry/distro/patches/_bedrock_agentcore_patches.py
Show resolved
Hide resolved
liustve
added a commit
that referenced
this pull request
Oct 31, 2025
*Description of changes:* Follow up to: #490 1. Normalizes `AWS::Bedrock AgentCore` and `AWS::Bedrock AgentCore Control` from botocore instrumentation to `AWS::BedrockAgentCore` 2. Add Resource and CFN attributes for Bedrock AgentCore support as following: a. **Runtime**: Extract `agentRuntimeId` or parse from `agentRuntimeArn` and add into `aws.remote.resource.identifier` span attribute. Set `aws.remote.resource.type` to `AWS::BedrockAgentCore::Runtime`. b. **Runtime Endpoint**: Extract endpoint ID from `agentRuntimeEndpointArn` and add into `aws.remote.resource.identifier` span attribute, but use full ARN as `aws.cloudformation.primary.identifier`. Set `aws.remote.resource.type` to `AWS::BedrockAgentCore::RuntimeEndpoint`. c. **Browser**: Extract `browserIdentifier` or parse from `browserArn`, and add into `aws.remote.resource.identifier` span attribute. Set `aws.remote.resource.type` to `AWS::BedrockAgentCore::Browser` (for `aws.browser.v1`) or `AWS::BedrockAgentCore::BrowserCustom` (for custom browsers). d. **Gateway**: Extract `gatewayId` or parse from `gatewayArn`, and add into `aws.remote.resource.identifier` span attribute. Set `aws.remote.resource.type` to `AWS::BedrockAgentCore::Gateway`. e. **Gateway Target**: Extract `targetId` from span attributes and add into `aws.remote.resource.identifier` span attribute. Set `aws.remote.resource.type` to `AWS::BedrockAgentCore::GatewayTarget`. Takes priority over Gateway when present. f. **Code Interpreter**: Extract `codeInterpreterIdentifier` or parse from `codeInterpreterArn`, and add into `aws.remote.resource.identifier` span attribute. Set `aws.remote.resource.type` to `AWS::BedrockAgentCore::CodeInterpreter` (for `aws.codeinterpreter.v1`) or `AWS::BedrockAgentCore::CodeInterpreterCustom` (for custom interpreters). g. **Memory**: Extract `memoryId` or parse from `memoryArn` and add into `aws.remote.resource.identifier` span attribute, but use full ARN as `aws.cloudformation.primary.identifier` when available. Set `aws.remote.resource.type` to `AWS::BedrockAgentCore::Memory`. h. **Identity**: Extract provider ID from credential provider ARNs for OAuth2 and API Key credential providers and add into `aws.remote.resource.identifier` span attribute. Set `aws.remote.resource.type` to `AWS::BedrockAgentCore::OAuth2CredentialProvider` or `AWS::BedrockAgentCore::APIKeyCredentialProvider`. **Testing** 1. Contract tests added to validate E2E behavior of new Application Signals attributes. 2. Unit tests added to validate logic flow is as expected. 3. Manual testing to verify the new spans: ``` { "name": "Bedrock AgentCore.InvokeAgentRuntime", "context": { "trace_id": "0x68f7e9d8113e41fe74ca4bedf2aee364", "span_id": "0xff15834f0aa966ea", "trace_state": "[]" }, "kind": "SpanKind.CLIENT", "parent_id": null, "start_time": "2025-10-21T20:15:20.875227Z", "end_time": "2025-10-21T20:15:21.827053Z", "status": { "status_code": "UNSET" }, "attributes": { "rpc.system": "aws-api", "rpc.service": "Bedrock AgentCore", "rpc.method": "InvokeAgentRuntime", "aws.region": "us-west-2", "server.address": "bedrock-agentcore.us-west-2.amazonaws.com", "server.port": 443, "aws.auth.region": "us-west-2", "aws.auth.account.access_key": "", "aws.bedrock.agentcore.runtime.arn": "arn:aws:bedrock-agentcore:us-west-2:571600841604:runtime/app-B7cysl8fTW", "aws.local.operation": "InternalOperation", "aws.local.service": "test-genesis", "aws.remote.service": "AWS::BedrockAgentCore", "aws.remote.operation": "InvokeAgentRuntime", "aws.remote.resource.type": "AWS::BedrockAgentCore::Runtime", "aws.remote.resource.identifier": "app-B7cysl8fTW", "aws.remote.resource.cfn.primary.identifier": "app-B7cysl8fTW", "aws.remote.resource.account.access_key": "ASIAYKFQQVOCK7JJYIFI", "aws.remote.resource.region": "us-west-2", "aws.span.kind": "LOCAL_ROOT" }, "events": [], "links": [], "resource": { "attributes": { "telemetry.sdk.language": "python", "telemetry.sdk.name": "opentelemetry", "telemetry.sdk.version": "1.33.1", "service.name": "test-genesis", "telemetry.auto.version": "0.12.1.dev0-aws", "aws.local.service": "test-genesis" }, "schema_url": "" } } ``` ``` { "name": "Bedrock AgentCore.CreateEvent", "context": { "trace_id": "0x68f811f6b5b57a276e378106ac9f7bca", "span_id": "0xc60262df93b1c44f", "trace_state": "[]" }, "kind": "SpanKind.CLIENT", "parent_id": "0x98a57a740465b917", "start_time": "2025-10-21T23:06:36.435203Z", "end_time": "2025-10-21T23:06:37.069681Z", "status": { "status_code": "UNSET" }, "attributes": { "rpc.system": "aws-api", "rpc.service": "Bedrock AgentCore", "rpc.method": "CreateEvent", "aws.region": "us-west-2", "server.address": "bedrock-agentcore.us-west-2.amazonaws.com", "server.port": 443, "aws.auth.region": "us-west-2", "aws.auth.account.access_key": "", "gen_ai.memory.id": "app_mem-ZPNcI839KD", "aws.local.operation": "POST /invocations", "aws.request_id": "0eabdad1-6ab4-4efb-98c5-ef1b9bbe028a", "retry_attempts": 1, "http.status_code": 201, "aws.local.service": "test-genesis", "aws.remote.service": "AWS::BedrockAgentCore", "aws.remote.operation": "CreateEvent", "aws.remote.resource.type": "AWS::BedrockAgentCore::Memory", "aws.remote.resource.identifier": "app_mem-ZPNcI839KD", "aws.remote.resource.cfn.primary.identifier": "app_mem-ZPNcI839KD", "aws.remote.resource.account.access_key": "", "aws.remote.resource.region": "us-west-2", "aws.span.kind": "CLIENT" }, "events": [], "links": [], "resource": { "attributes": { "telemetry.sdk.language": "python", "telemetry.sdk.name": "opentelemetry", "telemetry.sdk.version": "1.33.1", "service.name": "test-genesis", "telemetry.auto.version": "0.12.1.dev0-aws", "aws.local.service": "test-genesis" }, "schema_url": "" } } ``` By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice. --------- Co-authored-by: ADOT Patch workflow <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of changes:
Patches botocore instrumentor to add span attributes for Bedrock AgentCore control and data plane calls.
_BedrockAgentCoreExtensionto extract telemetry attributes from API parametersbedrock-agentcore(data plane) andbedrock-agentcore-control(control plane)New semantic conventions based off this PR:
open-telemetry/semantic-conventions#2886
Manually tested verified span attributes examples:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.