BraintrustExporter
Sends Tracing data to Braintrust for eval and observability.
ConstructorConstructor的直接链接
new BraintrustExporter(config: BraintrustExporterConfig)
BraintrustExporterConfigbraintrustexporterconfig的直接链接
interface BraintrustExporterConfig extends BaseExporterConfig {
apiKey?: string
endpoint?: string
projectName?: string
braintrustLogger?: Logger<true>
currentSpan?: () => Span | undefined
tuningParameters?: Record<string, any>
}
Extends BaseExporterConfig, which includes:
logger?: IMastraLogger- Logger instancelogLevel?: LogLevel | 'debug' | 'info' | 'warn' | 'error'- Log level (default: INFO)
MethodsMethods的直接链接
exportTracingEventexporttracingevent的直接链接
async exportTracingEvent(event: TracingEvent): Promise<void>
Exports a tracing event to Braintrust.
exportexport的直接链接
async export(spans: ReadOnlySpan[]): Promise<void>
Batch exports spans to Braintrust.
flushflush的直接链接
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.
shutdownshutdown的直接链接
async shutdown(): Promise<void>
Flushes pending data and shuts down the client.
UsageUsage的直接链接
Zero-Config (using environment variables)Zero-Config (using environment variables)的直接链接
import { BraintrustExporter } from '@mastra/braintrust'
// Reads from BRAINTRUST_API_KEY, BRAINTRUST_ENDPOINT
const exporter = new BraintrustExporter()
Explicit ConfigurationExplicit Configuration的直接链接
import { BraintrustExporter } from '@mastra/braintrust'
const exporter = new BraintrustExporter({
apiKey: process.env.BRAINTRUST_API_KEY,
projectName: 'my-ai-project',
})
Span type mappingSpan type mapping的直接链接
| Span Type | Braintrust Type |
|---|---|
MODEL_GENERATION | llm |
MODEL_CHUNK | llm |
TOOL_CALL | tool |
MCP_TOOL_CALL | tool |
PROVIDER_TOOL_CALL | tool |
WORKFLOW_CONDITIONAL_EVAL | function |
WORKFLOW_WAIT_EVENT | function |
| All others | task |