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.
Summary
Goal: Emit traces to two separate projects with distinct root spans simultaneously.
Features: Multiple logger instances with independent project targets and setCurrent: false configuration.
Configuration Steps
Step 1: Create primary logger
Initialize the main logger for your primary project.
// TypeScript
import { initLogger } from "braintrust";
const primaryLogger = initLogger({
projectName: "my-primary-project",
apiKey: process.env.BRAINTRUST_API_KEY,
});
# Python
from braintrust import init_logger
primary_logger = init_logger(
project="my-primary-project",
api_key=os.environ["BRAINTRUST_API_KEY"],
)
Step 2: Create secondary logger with setCurrent: false
Initialize a second logger targeting the other project with setCurrent: false to prevent conflicts.
// TypeScript
const secondaryLogger = initLogger({
projectName: "shared-visibility-project",
apiKey: process.env.BRAINTRUST_API_KEY,
setCurrent: false, // Prevents this logger from becoming the global default
});
# Python
secondary_logger = init_logger(
project="shared-visibility-project",
api_key=os.environ["BRAINTRUST_API_KEY"],
set_current=False, # Prevents this logger from becoming the global default
)
Step 3: Log to both projects
Use each logger instance to create distinct traces in their respective projects.
// TypeScript
primaryLogger.log({ input: "request", output: "response" });
secondaryLogger.log({ input: "request", output: "response" });
# Python
primary_logger.log(input="request", output="response")
secondary_logger.log(input="request", output="response")
Use Case Example
Emit traces to both a shared service project and the consuming application’s project for dual visibility without post-processing.