> ## Documentation Index
> Fetch the complete documentation index at: https://braintrust.dev/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Troubleshooting

> Diagnose and fix common issues when installing or using the Braintrust Go SDK.

This page outlines common issues when setting up and using the Braintrust Go SDK and how to resolve them.

<AccordionGroup>
  <Accordion title="No traces after adding the SDK">
    Confirm that your application initializes Braintrust during startup and uses the tracer provider you registered with OpenTelemetry:

    ```go theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
    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.
  </Accordion>

  <Accordion title="Provider calls are not auto-instrumented">
    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:

    ```bash theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
    orchestrion go run .
    orchestrion go build ./...
    ```

    If the app is run with plain `go run` or `go build`, Orchestrion will not inject provider instrumentation.
  </Accordion>

  <Accordion title="An integration package is missing">
    Make sure `orchestrion.tool.go` imports the contrib package for the provider library your app uses, then run `go mod tidy`:

    ```go #skip-compile theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
    //go:build tools

    package main

    import (
    	_ "github.com/DataDog/orchestrion"
    	_ "github.com/braintrustdata/braintrust-sdk-go/trace/contrib/openai"
    )
    ```

    See [SDK integrations](/sdks/go/sdk-integrations) for supported import paths.
  </Accordion>

  <Accordion title="Traces are written to the wrong project">
    Pass the target project when creating the Braintrust client:

    ```go theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
    _, err := braintrust.New(tp, braintrust.WithProject("My project"))
    if err != nil {
    	log.Fatal(err)
    }
    ```
  </Accordion>

  <Accordion title="No traces from a short-lived program">
    Short-lived programs can exit before spans are exported. Shut down the tracer provider before the process exits:

    ```go theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
    defer func() {
    	if err := tp.Shutdown(context.Background()); err != nil {
    		log.Printf("failed to shut down tracer provider: %v", err)
    	}
    }()
    ```
  </Accordion>
</AccordionGroup>
