Skip to main content
This page outlines common issues when setting up and using the Braintrust Go SDK and how to resolve them.
Confirm that your application initializes Braintrust during startup and uses the tracer provider you registered with OpenTelemetry:
tp := trace.NewTracerProvider()
otel.SetTracerProvider(tp)

_, err := braintrust.New(tp, braintrust.WithProject("My project"))
if err != nil {
	log.Fatal(err)
}
Also confirm that BRAINTRUST_API_KEY is set in the environment used to run the application.
Auto-instrumentation only works when your app is built or run through Orchestrion. Use the same command path your team uses in development, CI, or production:
orchestrion go run .
orchestrion go build ./...
If the app is run with plain go run or go build, Orchestrion will not inject provider instrumentation.
Make sure orchestrion.tool.go imports the contrib package for the provider library your app uses, then run go mod tidy:
#skip-compile
//go:build tools

package main

import (
	_ "github.com/DataDog/orchestrion"
	_ "github.com/braintrustdata/braintrust-sdk-go/trace/contrib/openai"
)
See SDK integrations for supported import paths.
Pass the target project when creating the Braintrust client:
_, err := braintrust.New(tp, braintrust.WithProject("My project"))
if err != nil {
	log.Fatal(err)
}
Short-lived programs can exit before spans are exported. Shut down the tracer provider before the process exits:
defer func() {
	if err := tp.Shutdown(context.Background()); err != nil {
		log.Printf("failed to shut down tracer provider: %v", err)
	}
}()