BraintrustExporter
Sends Tracing data to Braintrust for eval and observability.
ConstructorDirect link to Constructor
new BraintrustExporter(config: BraintrustExporterConfig)
BraintrustExporterConfigDirect link to BraintrustExporterConfig
interface BraintrustExporterConfig extends BaseExporterConfig {
apiKey?: string;
endpoint?: string;
projectName?: string;
tuningParameters?: Record<string, any>;
}
Extends BaseExporterConfig, which includes:
logger?: IMastraLogger- Logger instancelogLevel?: LogLevel | 'debug' | 'info' | 'warn' | 'error'- Log level (default: INFO)
MethodsDirect link to Methods
exportTracingEventDirect link to exportTracingEvent
async exportTracingEvent(event: TracingEvent): Promise<void>
Exports a tracing event to Braintrust.
exportDirect link to export
async export(spans: ReadOnlySpan[]): Promise<void>
Batch exports spans to Braintrust.
flushDirect link to flush
async flush(): Promise<void>
Force flushes any buffered spans to Braintrust without shutting down the exporter. Useful in serverless environments where you need to ensure spans are exported before the runtime terminates.
shutdownDirect link to shutdown
async shutdown(): Promise<void>
Flushes pending data and shuts down the client.
UsageDirect link to Usage
Zero-Config (using environment variables)Direct link to Zero-Config (using environment variables)
import { BraintrustExporter } from "@mastra/braintrust";
// Reads from BRAINTRUST_API_KEY, BRAINTRUST_ENDPOINT
const exporter = new BraintrustExporter();
Explicit ConfigurationDirect link to Explicit Configuration
import { BraintrustExporter } from "@mastra/braintrust";
const exporter = new BraintrustExporter({
apiKey: process.env.BRAINTRUST_API_KEY,
projectName: "my-ai-project",
});
Span Type MappingDirect link to Span Type Mapping
| Span Type | Braintrust Type |
|---|---|
MODEL_GENERATION | llm |
MODEL_CHUNK | llm |
TOOL_CALL | tool |
MCP_TOOL_CALL | tool |
WORKFLOW_CONDITIONAL_EVAL | function |
WORKFLOW_WAIT_EVENT | function |
| All others | task |