BraintrustExporter
将 Tracing 数据发送到 Braintrust,用于评估和可观测性。
构造函数构造函数的直接链接
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>
}
扩展 BaseExporterConfig,其中包含:
logger?: IMastraLogger- Logger 实例logLevel?: LogLevel | 'debug' | 'info' | 'warn' | 'error'- 日志级别(默认值:INFO)
方法方法的直接链接
exportTracingEventexporttracingevent的直接链接
async exportTracingEvent(event: TracingEvent): Promise<void>
将 Tracing 事件导出到 Braintrust。
exportexport的直接链接
async export(spans: ReadOnlySpan[]): Promise<void>
将 Span 批量导出到 Braintrust。
flushflush的直接链接
async flush(): Promise<void>
强制将缓冲区中的所有 Span 刷新到 Braintrust,而不关闭 Exporter。适用于需要确保运行时终止前已导出 Span 的 serverless 环境。
shutdownshutdown的直接链接
async shutdown(): Promise<void>
刷新待处理数据并关闭客户端。
用法用法的直接链接
零配置(使用环境变量)零配置(使用环境变量)的直接链接
import { BraintrustExporter } from '@mastra/braintrust'
// Reads from BRAINTRUST_API_KEY, BRAINTRUST_ENDPOINT
const exporter = new BraintrustExporter()
显式配置显式配置的直接链接
import { BraintrustExporter } from '@mastra/braintrust'
const exporter = new BraintrustExporter({
apiKey: process.env.BRAINTRUST_API_KEY,
projectName: 'my-ai-project',
})
Span 类型映射Span 类型映射的直接链接
| Span 类型 | Braintrust 类型 |
|---|---|
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 |
| 所有其他类型 | task |