You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: Add Resource and CFN Attributes for Bedrock AgentCore spans (#495)
*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]>
0 commit comments