Third-party frameworks on AgentCore Runtime
When you run LangChain, LlamaIndex, CrewAI, or the OpenAI Agents SDK on Amazon Bedrock AgentCore Runtime, you want the instrumentation that makes cost attribute correctly, so cost ties to the right session and agent.
What Runtime supplies automatically
As with any agent on AgentCore Runtime, Runtime creates and propagates the session id and derives the agent identity. You do not wire those by hand. What you own is the instrumentation that produces accurate model-call telemetry.
Step 1: Instrument with ADOT
Install the AWS Distro for OpenTelemetry (ADOT):
ADOT is not bundled. AgentCore Runtime injects the OpenTelemetry environment variables, but you must install ADOT and start the agent under it. For Python, add ADOT and its dependencies to requirements.txt (add your framework’s package alongside them):
aws-opentelemetry-distro>=0.22.0 # 0.18.0 = AgentCore observability minimum; 0.22.0 = prompt-cache tokens priced bedrock-agentcore boto3
Start the agent under ADOT’s auto-instrumentation. For a container image, set the Dockerfile
CMD:
CMD ["opentelemetry-instrument", "python", "main.py"]
For direct code deployment, set the entryPoint in agentRuntimeArtifact.codeConfiguration:
"entryPoint": ["opentelemetry-instrument", "main.py"]
ADOT 0.18.0 is the minimum for AgentCore observability; 0.16.0 is the minimum for OTEL_BAGGAGE_SPAN_ATTRIBUTE_KEYS (per-tenant cost); and 0.22.0 is the minimum to price cache-read and cache-write tokens. No minimum bedrock-agentcore SDK version is needed for cost.
ADOT’s built-in instrumentors cover these frameworks. You can also pair a third-party instrumentation library (Traceloop/OpenLLMetry, OpenInference, or OpenLIT) with ADOT; that combination is supported, as long as ADOT produces the telemetry.
Step 2: If your model provider is not Amazon Bedrock
Add the matching GenAI instrumentation package so token counts are recorded:
pip install opentelemetry-instrumentation-genai-openai # OR pip install opentelemetry-instrumentation-genai-anthropic # OR pip install opentelemetry-instrumentation-google-genai
Step 3: If you pair Traceloop with Amazon Bedrock, avoid double-counted tokens
Traceloop (OpenLLMetry) and Bedrock instrumentation can both record the same model call, which double-counts tokens. Disable the overlapping instrumentation:
export OTEL_PYTHON_DISABLED_INSTRUMENTATIONS=botocore
This disables spans for all AWS SDK calls. If you use ADOT Python 0.23.0 or later, disable only the Bedrock instrumentation instead:
export OTEL_PYTHON_DISABLED_INSTRUMENTATIONS=bedrock
Third-party instrumentation libraries follow their own schemas and can emit extra model spans. When telemetry is produced by ADOT, each model call is counted once. This is why cost attribution depends on ADOT producing the telemetry.
Step 4: Pass the attributes
Pass a runtimeSessionId of at least 33 characters on each invoke. To attribute cost to a tenant, pass baggage="aws.tenant.id=<your tenant>" on each invoke and set this environment variable on the agent runtime (ADOT 0.16.0 or later) so ADOT copies the tenant onto spans:
export OTEL_BAGGAGE_SPAN_ATTRIBUTE_KEYS=aws.tenant.id
session.id is copied automatically; the tenant is not, so without this variable per-tenant cost does not appear. You must set the tenant on every agent runtime and instance, because each process copies baggage only onto the spans it creates. See Pass the required session and agent attributes.
Step 5: Turn on tracing for the agent runtime and for each AgentCore resource it uses
Turn on tracing for the agent runtime itself and for each AgentCore resource the agent uses (Gateway, Memory, Code Interpreter, Browser), with the console’s Enable tracing. Without it, only the agent’s ADOT model-call spans reach aws/spans, so no Runtime, Gateway, Memory, Code Interpreter, or Browser cost appears.
Transaction Search must also be on for the account and Region. This is a one-time per-account setup; if you deploy with the AgentCore CLI, agentcore deploy turns it on for you.
Cost dimensions covered
All in-path primitives, the same as Strands on Runtime, when the attributes flow correctly. A call whose attributes are missing can show a dash or land unattributed rather than attributing to the session. See Cost estimate coverage and limits and Cost is attributed to the wrong agent.
If you use plain OpenTelemetry instead of ADOT
The steps above use ADOT, the recommended path. If you instrument your framework on AgentCore Runtime with plain OpenTelemetry instead of ADOT, cost attributes when you do the following. AgentCore Runtime already sets the agent identity, so you do not set it yourself.
-
Use the session id Runtime supplies. Read it from
BedrockAgentCoreContext.get_session_id()if your agent uses the AgentCore Python SDK app, or from theX-Amzn-Bedrock-AgentCore-Runtime-Session-Idrequest header. A sub-agent uses the session id its caller passed along. -
Add the AWS X-Ray trace format to your propagators, or the agent’s spans are not linked to the Runtime trace:
export OTEL_PROPAGATORS=tracecontext,xray,baggage -
Emit the model-call span, pass the values in baggage, and copy them onto your own spans, as in Steps 5 to 7 of Self-hosted compute.
Confirm
See Check your setup is ready for cost.