LangSmith Go supports OpenTelemetry for distributed tracing. This allows you to automatically capture and send traces from your LLM applications.
Configure tracing using environment variables:
| Variable | Description |
|---|---|
LANGSMITH_API_KEY |
Your LangSmith API key |
LANGSMITH_ENDPOINT |
Custom API endpoint (defaults to https://api.smith.langchain.com) |
LANGSMITH_PROJECT |
Project name for traces |
import (
"github.com/langchain-ai/langsmith-go"
"go.opentelemetry.io/otel"
)
// Create a new tracer
tracer := langsmith.NewTracer()
// Use with OpenTelemetry
ctx, span := otel.Tracer("my-app").Start(ctx, "operation")
defer span.End()
See the otel_openai example for automatic tracing of OpenAI API calls.
See the otel_anthropic example for automatic tracing of Anthropic API calls.