Amazon Bedrock
InvokeModel, Converse, and ConverseStream auto-capture with per-provider model strings.
Install the instrumentor and every Bedrock client call inside wrap your agent becomes a span. The provider field is the model family (anthropic, meta, amazon, cohere, mistral, ai21), extracted from the modelId.
What's captured
| Call | Span kind | Auto-extracted |
|---|---|---|
Converse | llm | Python: model, input/output tokens, stop_reason, messages. Node: model only (the Node instrumentor parses InvokeModel bodies; wrap Converse calls with trodo.llm for tokens) |
ConverseStream | llm | same caveat as Converse |
InvokeModel | llm | model + per-model-family tokens/messages (both languages) |
Prefer Converse on Python — it's uniform and fully auto-captured. InvokeAgent (Bedrock Agents, the separate bedrock-agent-runtime client) is not auto-instrumented in either language — wrap it with manual spans.
Install
npm install @aws-sdk/client-bedrock-runtime @traceloop/instrumentation-bedrockpip install boto3 opentelemetry-instrumentation-bedrockMinimal example — Converse
import trodo from 'trodo-node';
import { BedrockRuntimeClient, ConverseCommand } from '@aws-sdk/client-bedrock-runtime';
trodo.init({ siteId: process.env.TRODO_SITE_ID });
const client = new BedrockRuntimeClient({ region: 'us-east-1' });
await trodo.wrapAgent('bedrock-converse', async (run) => {
const r = await client.send(new ConverseCommand({
modelId: 'anthropic.claude-3-5-sonnet-20241022-v2:0',
messages: [{ role: 'user', content: [{ text: 'Explain vector databases.' }] }],
}));
run.setOutput(r.output.message.content[0].text);
});import os, trodo, boto3
trodo.init(site_id=os.environ['TRODO_SITE_ID'])
client = boto3.client('bedrock-runtime', region_name='us-east-1')
with trodo.wrap_agent('bedrock-converse') as run:
r = client.converse(
modelId='anthropic.claude-3-5-sonnet-20241022-v2:0',
messages=[{'role': 'user', 'content': [{'text': 'Explain vector databases.'}]}],
)
run.set_output(r['output']['message']['content'][0]['text'])