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

CallSpan kindAuto-extracted
Conversellmmodel, input/output tokens, stop_reason, messages
ConverseStreamllmsame, accumulated
InvokeModelllmmodel; body is provider-specific
InvokeAgentagentagent id, session id, trace events

Prefer Converse: it's uniform and fully auto-captured.

Install

npm install @aws-sdk/client-bedrock-runtime @opentelemetry/instrumentation-bedrock
pip install boto3 opentelemetry-instrumentation-bedrock

Minimal 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'])

On this page