config

package
v0.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 15, 2026 License: Apache-2.0 Imports: 7 Imported by: 2 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package config provides configuration management for the Braintrust SDK.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIKeyResolver added in v0.8.0

type APIKeyResolver interface {
	APIKey(context.Context) (string, bool)
}

APIKeyResolver resolves a Braintrust API key when one is not provided explicitly or through the process environment.

type Config

type Config struct {
	APIKey             string
	APIKeyResolver     APIKeyResolver
	APIURL             string
	AppURL             string
	OrgName            string
	DefaultProjectID   string
	DefaultProjectName string
	BlockingLogin      bool

	// Tracing configuration
	FilterAISpans            bool
	EnableBuiltinAdkTraces   bool // if false (default), drop Google ADK native spans to avoid duplicates
	EnableTraceConsoleLog    bool // log traces to stdout for debugging
	AutoConvertAIAttachments bool // scan spans for base64 attachments and upload them (default: true)
	SpanFilterFuncs          []SpanFilterFunc
	Exporter                 trace.SpanExporter

	// Logger
	Logger logger.Logger
}

Config holds immutable configuration for the Braintrust SDK.

func FromEnv

func FromEnv() *Config

FromEnv loads configuration from environment variables with defaults. If BRAINTRUST_API_KEY is unset or blank, API key discovery can fall back to the nearest .braintrust.json file when authentication or export first needs it.

Supported environment variables:

  • BRAINTRUST_API_KEY: API key for authentication
  • BRAINTRUST_API_URL: API endpoint URL (default: "https://api.braintrust.dev")
  • BRAINTRUST_APP_URL: Application URL (default: "https://www.braintrust.dev")
  • BRAINTRUST_ORG_NAME: Organization name
  • BRAINTRUST_DEFAULT_PROJECT_ID: Default project ID
  • BRAINTRUST_DEFAULT_PROJECT: Default project name (default: "default-go-project")
  • BRAINTRUST_BLOCKING_LOGIN: Enable blocking login (default: false)
  • BRAINTRUST_ENABLE_TRACE_CONSOLE_LOG: Log traces to stdout for debugging (default: false)
  • BRAINTRUST_OTEL_FILTER_AI_SPANS: Filter to keep only AI-related spans (default: false)
  • BRAINTRUST_OTEL_ENABLE_BUILTIN_ADK_TRACES: Enable exporting spans from Google ADK's built-in telemetry (default: false)
  • BRAINTRUST_AUTO_CONVERT_AI_ATTACHMENTS: Scan spans for base64 attachments and upload them (default: true)

func (*Config) IsValid

func (c *Config) IsValid() error

IsValid checks if the configuration has all required fields. Returns an error if any required field is missing.

type SpanFilterFunc

type SpanFilterFunc func(span trace.ReadOnlySpan) int

SpanFilterFunc is a function that decides which spans to send to Braintrust. Return >0 to keep the span, <0 to drop the span, or 0 to not influence the decision.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL