AWS Bedrock
Instrument Bedrock Runtime and Agent Runtime in TypeScript or Python. Converse, InvokeModel, agents, flows, and knowledge bases traced with tokens and cost.
Built by
telemetry.dev
Language
TypeScript + Python
Packages
@telemetry-dev/bedrock · telemetry-dev-bedrock
Category
Model providers
Docs
About the AWS Bedrock integration
@telemetry-dev/bedrock instruments AWS SDK for JavaScript v3 clients; telemetry-dev-bedrock does the same for boto3/botocore. Both cover Bedrock Runtime — Converse, ConverseStream, InvokeModel, InvokeModelWithResponseStream, ApplyGuardrail — and Bedrock Agent Runtime: InvokeAgent, InvokeInlineAgent, Retrieve, RetrieveAndGenerate, and InvokeFlow. Requests are never modified, which keeps SigV4 signing and request reuse intact.
Key features
- Converse and InvokeModel: Converse messages are normalized to the OpenTelemetry GenAI message shapes; InvokeModel captures provider-native JSON bodies verbatim, with usage for Claude, Titan/Nova, and Llama models.
- Agents, flows, and knowledge bases: Agent invocations, retrievals, and RAG calls become typed spans —
invoke_agent,retrieve,retrieve_and_generate,invoke_flow— with trace usage aggregation. - Streams preserve backpressure: Stream wrappers are pull-through, record time-to-first-chunk, and end spans exactly once with partial output on early break, abort, or error.
- Guardrails:
ApplyGuardrailcalls capture input, output, action, and reason. - Accurate Bedrock pricing: Provider is emitted as
amazon-bedrockso cost keys match Bedrock model IDs exactly.
Get started
import { BedrockRuntimeClient, ConverseCommand } from "@aws-sdk/client-bedrock-runtime";
import { init, shutdown } from "@telemetry-dev/sdk";
import { wrapBedrock } from "@telemetry-dev/bedrock";
init({ apiKey: process.env.TELEMETRY_DEV_API_KEY, serviceName: "bedrock-app" });
const bedrock = wrapBedrock(new BedrockRuntimeClient({ region: "us-east-1" }));
await bedrock.send(
new ConverseCommand({
modelId: "anthropic.claude-3-5-haiku-20241022-v1:0",
messages: [{ role: "user", content: [{ text: "Hello" }] }],
}),
);
await shutdown();
Python uses the same shape with boto3 clients via wrap_bedrock. For app-wide coverage, instrumentBedrock() shadows BedrockRuntimeClient.prototype.send without touching other AWS SDK clients, and Agent Runtime support lives in the optional @telemetry-dev/bedrock/agents entry point.