Skip to main content
LangWatch provides native instrumentation for the AWS Bedrock Runtime client (github.com/aws/aws-sdk-go-v2/service/bedrockruntime). Unlike the HTTP-bytes instrumentations, Bedrock is traced via the AWS smithy-go middleware stack, reading the typed operation input/output structs directly, so there is no body buffering. It captures Converse, ConverseStream and (best-effort) InvokeModel, including cache read + write tokens and latency.

Installation

Usage

Set LANGWATCH_API_KEY before running, and ensure your AWS credentials and region are configured (e.g. via AWS_REGION and the standard AWS credential chain).
Instrument an aws.Config once with InstrumentConfig, and every Bedrock Runtime client built from it is traced:

Instrumenting a single client or operation

If you do not want to mutate the shared aws.Config, add the middleware to a single client (or call) via APIOptions:
The middleware captures input and output content by default (langwatch.DataCaptureAll). Pass bedrock.WithDataCapture(langwatch.DataCaptureNone) to InstrumentConfig / WithTracing to opt out. Use bedrock.WithGenAIProvider(...) to attribute spans to the underlying foundation-model vendor instead of aws.bedrock.
Close streaming responses. For ConverseStream, the span is finalised when the stream drains, Close() is called, or the operation context is cancelled, so always defer stream.Close() (or pass a cancellable context), exactly as you would for any AWS event stream.
The defer tp.Shutdown(ctx) call is essential. Without it, traces buffered in memory will be lost when your application exits.

Check it worked

Run the program with go run .. The deferred tp.Shutdown(ctx) flushes the spans when main returns. Then open your project in LangWatch: a new trace appears in the traces list within a few seconds, with the Bedrock call as an LLM span carrying its input, output and token counts. If no trace appears, check that LANGWATCH_API_KEY is set in the environment the program runs in.
Last modified on October 29, 2026