feat(botocore): propagate trace context to Bedrock AgentCore InvokeAgentRuntime#18591
feat(botocore): propagate trace context to Bedrock AgentCore InvokeAgentRuntime#18591ncybul wants to merge 1 commit into
Conversation
|
Codeowners resolved as |
BenchmarksBenchmark execution time: 2026-06-11 20:15:16 Comparing candidate commit b34289f in PR branch Found 0 performance improvements and 1 performance regressions! Performance is the same for 384 metrics, 9 unstable metrics. scenario:span-start
|
Description
Adds distributed-trace context propagation for Amazon Bedrock AgentCore
InvokeAgentRuntimecalls.AgentCore exposes W3C trace context as first-class request parameters
(
traceParent/traceState/baggage) that it forwards to the agentcontainer 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 (viathe
t.llmobs_*fields carried intraceState).Changes:
contrib/internal/botocore/utils.py:update_agentcore_traceparent()maps theinjected W3C headers (
traceparent/tracestate/baggage) onto the AgentCorerequest params, preserving any user-provided values.
contrib/internal/botocore/patch.py: routebedrock-agentcore/InvokeAgentRuntimeto the new injector._trace/trace_handlers.py: register thebotocore.agentcore.update_messageslistener.
llmobs/_llmobs.py: includebedrock-agentcorein the botocore submodulespatched 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-agentcoreworkflow → agentstrands-agent→bedrock-runtimeLLM span). Automated tests are a follow-up.Risks
Low. Scoped to the
bedrock-agentcore/InvokeAgentRuntimeoperation;user-provided
traceParent/traceState/baggageparams are preserved.Additional Notes
Claude session:
d880cf25-602f-4da8-b814-7c84bd27e92aResume:
claude --resume d880cf25-602f-4da8-b814-7c84bd27e92a