Skip to content

feat(botocore): propagate trace context to Bedrock AgentCore InvokeAgentRuntime#18591

Draft
ncybul wants to merge 1 commit into
mainfrom
nicole-cybul/bedrock-agentcore-trace-propagation
Draft

feat(botocore): propagate trace context to Bedrock AgentCore InvokeAgentRuntime#18591
ncybul wants to merge 1 commit into
mainfrom
nicole-cybul/bedrock-agentcore-trace-propagation

Conversation

@ncybul

@ncybul ncybul commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Description

Adds distributed-trace context propagation for Amazon Bedrock AgentCore
InvokeAgentRuntime calls.

AgentCore exposes W3C trace context as first-class request parameters
(traceParent / traceState / baggage) that it forwards to the agent
container as the corresponding HTTP headers. This change injects the active
trace context onto those parameters so the agent runtime continues the caller's
distributed trace — in both APM (via traceParent) and LLM Observability (via
the t.llmobs_* fields carried in traceState).

Changes:

  • contrib/internal/botocore/utils.py: update_agentcore_traceparent() maps the
    injected W3C headers (traceparent/tracestate/baggage) onto the AgentCore
    request params, preserving any user-provided values.
  • contrib/internal/botocore/patch.py: route bedrock-agentcore /
    InvokeAgentRuntime to the new injector.
  • _trace/trace_handlers.py: register the botocore.agentcore.update_messages
    listener.
  • llmobs/_llmobs.py: include bedrock-agentcore in the botocore submodules
    patched when LLMObs is enabled (so the injector is not short-circuited).

Testing

Validated end-to-end against a deployed Strands agent on AgentCore Runtime: a
ddtrace-instrumented client and the agent connect into a single trace in both
APM and LLM Observability (client invoke-agentcore workflow → agent
strands-agentbedrock-runtime LLM span). Automated tests are a follow-up.

Risks

Low. Scoped to the bedrock-agentcore / InvokeAgentRuntime operation;
user-provided traceParent/traceState/baggage params are preserved.

Additional Notes

Claude session: d880cf25-602f-4da8-b814-7c84bd27e92a
Resume: claude --resume d880cf25-602f-4da8-b814-7c84bd27e92a

@datadog-prod-us1-5

datadog-prod-us1-5 Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Pipelines  Tests

Fix all issues with BitsAI

⚠️ Warnings

🚦 9 Pipeline jobs failed

DataDog/apm-reliability/dd-trace-py | build linux serverless: [amd64, cp315-cp315, v113741238-d2b8243-manylinux2014_x86_64, 1]   View in Datadog   GitLab

DataDog/apm-reliability/dd-trace-py | build linux serverless: [amd64, cp315-cp315, v113741491-d2b8243-musllinux_1_2_x86_64, 1]   View in Datadog   GitLab

DataDog/apm-reliability/dd-trace-py | build linux serverless: [arm64, cp315-cp315, v113741357-d2b8243-manylinux2014_aarch64, 1]   View in Datadog   GitLab

View all 9 failed jobs.

ℹ️ Info

No other issues found (see more)

🧪 All tests passed
❄️ No new flaky tests detected

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: b34289f | Docs | Datadog PR Page | Give us feedback!

@cit-pr-commenter-54b7da

Copy link
Copy Markdown

Codeowners resolved as

ddtrace/_trace/trace_handlers.py                                        @DataDog/apm-sdk-capabilities-python @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/internal/botocore/patch.py                              @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/internal/botocore/utils.py                              @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/llmobs/_llmobs.py                                               @DataDog/ml-observability

@pr-commenter

pr-commenter Bot commented Jun 11, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-06-11 20:15:16

Comparing candidate commit b34289f in PR branch nicole-cybul/bedrock-agentcore-trace-propagation with baseline commit 42c7b35 in branch main.

Found 0 performance improvements and 1 performance regressions! Performance is the same for 384 metrics, 9 unstable metrics.

scenario:span-start

  • 🟥 execution_time [+1.232ms; +1.404ms] or [+8.005%; +9.117%]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant