跳到主要内容
非官方简体中文翻译,内容版权归 Mastra 所有,遵循 Apache-2.0 许可。

BraintrustExporter

Sends Tracing data to Braintrust for eval and observability.

Constructor
Constructor的直接链接

new BraintrustExporter(config: BraintrustExporterConfig)

BraintrustExporterConfig
braintrustexporterconfig的直接链接

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 instance
  • logLevel?: LogLevel | 'debug' | 'info' | 'warn' | 'error' - Log level (default: INFO)

Methods
Methods的直接链接

exportTracingEvent
exporttracingevent的直接链接

async exportTracingEvent(event: TracingEvent): Promise<void>

Exports a tracing event to Braintrust.

export
export的直接链接

async export(spans: ReadOnlySpan[]): Promise<void>

Batch exports spans to Braintrust.

flush
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.

shutdown
shutdown的直接链接

async shutdown(): Promise<void>

Flushes pending data and shuts down the client.

Usage
Usage的直接链接

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 Configuration
Explicit Configuration的直接链接

import { BraintrustExporter } from '@mastra/braintrust'

const exporter = new BraintrustExporter({
apiKey: process.env.BRAINTRUST_API_KEY,
projectName: 'my-ai-project',
})

Span type mapping
Span type mapping的直接链接

Span TypeBraintrust Type
MODEL_GENERATIONllm
MODEL_CHUNKllm
TOOL_CALLtool
MCP_TOOL_CALLtool
PROVIDER_TOOL_CALLtool
WORKFLOW_CONDITIONAL_EVALfunction
WORKFLOW_WAIT_EVENTfunction
All otherstask