LangWatch Go SDK integration guide for setting up LLM observability and tracing.
Get your LangWatch API Key
echo $LANGWATCH_API_KEY
Install SDK Packages
go mod tidy
and checking that all dependencies are resolved.Configure OpenTelemetry
Instrument Your OpenAI Client
Create Your First Trace
thread_id
.Tracer()
and LangWatchSpan
methods, see the Core SDK section in the reference.ctx
is crucial. It carries the active span information, ensuring that tracer.Start()
correctly creates a nested span instead of a new trace.Variable | Description |
---|---|
LANGWATCH_API_KEY | Required. Your LangWatch project API key. |
LANGWATCH_ENDPOINT | The LangWatch collector endpoint. Defaults to https://app.langwatch.ai . |
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT | A standard OpenTelemetry variable that can also be used to set the endpoint URL. If set, it overrides LANGWATCH_ENDPOINT . This must be set to the trace-specific endpoint https://app.langwatch.ai/api/otel/v1/traces |
Example | What It Shows | Description |
---|---|---|
Simple | Basic OpenAI instrumentation | Simple chat completion with tracing |
Custom Input/Output | Recording custom data | Fine-grained control over captured data |
Streaming | Streaming completions | Real-time capture of streaming responses |
Threads | Grouping conversations | Managing multi-turn conversations |
RAG | Retrieval patterns | Document retrieval and context tracking |
LANGWATCH_API_KEY
is set correctlygo mod tidy
to ensure all dependencies are properly resolved