DeepEvalExporter
將 Tracing 資料傳送至 Confident AI,以進行評估與可觀測性分析。由建構於 DeepEval SDK 之上的 @mastra/deepeval 匯出。
如需設定與使用方式,請參閱 Confident AI exporter。
建構函式「建構函式」的直接連結
new DeepEvalExporter(config?: DeepEvalExporterConfig)
DeepEvalExporterConfig「deepevalexporterconfig」的直接連結
interface DeepEvalExporterConfig extends BaseExporterConfig {
apiKey?: string
environment?: string
name?: string
tags?: string[]
metadata?: Record<string, any>
threadId?: string
userId?: string
testCaseId?: string
turnId?: string
metricCollection?: string
traceMetricCollection?: string
llmMetricCollection?: string
agentMetricCollection?: string
toolMetricCollectionMap?: Record<string, string>
prompt?: Prompt
debug?: boolean
traceCaptureSink?: (trace: Trace) => void
}
擴充 BaseExporterConfig,其中包括:
logger?: IMastraLogger- Logger 執行個體logLevel?: LogLevel | 'debug' | 'info' | 'warn' | 'error'- Log 層級(預設:INFO)
apiKey?:
string
Confident AI API key。若未設定,則使用 CONFIDENT_API_KEY 環境變數。找不到 key 時,exporter 會自行停用。
environment?:
string
Trace 環境。依序使用 CONFIDENT_TRACE_ENVIRONMENT 與 'development' 作為備援。
name?:
string
套用至每個 trace 的名稱。預設為 Mastra serviceName。
metadata?:
Record<string, any>
套用至每個 trace 的 metadata。
threadId?:
string
套用至每個 trace 的 Thread ID。根 span metadata 中的 threadId 會針對該請求覆寫此值。
userId?:
string
套用至每個 trace 的 User ID。根 span metadata 中的 userId 會針對該請求覆寫此值。
testCaseId?:
string
套用至每個 trace 的 test case ID。根 span metadata 中的 testCaseId 會針對該請求覆寫此值。
turnId?:
string
套用至每個 trace 的 turn ID。根 span metadata 中的 turnId 會針對該請求覆寫此值。
metricCollection?:
string
Trace 層級的指標集合。
traceMetricCollection?:
string
Trace 層級的指標集合。優先於 metricCollection。
llmMetricCollection?:
string
套用至 LLM span 的指標集合。
agentMetricCollection?:
string
套用至 Agent span 的指標集合。
toolMetricCollectionMap?:
Record<string, string>
依 Tool 名稱套用的指標集合。
prompt?:
Prompt
附加至 LLM span 的 Confident AI 代管 prompt 連結。
debug?:
boolean
將 exporter 設定與匯出錯誤記錄至 console。
traceCaptureSink?:
(trace: Trace) => void
在本機接收已完成的 trace,而不將其傳送至 Confident AI。用於離線評估。
logLevel?:
'debug' | 'info' | 'warn' | 'error'
Logger 層級(預設:'info')
方法「方法」的直接連結
exportTracingEvent「exporttracingevent」的直接連結
async exportTracingEvent(event: TracingEvent): Promise<void>
將 tracing 事件匯出至 Confident AI。從 Mastra span 串流建立 trace 樹狀結構,並在根 span 結束時傳送 trace。
flush「flush」的直接連結
async flush(): Promise<void>
等待所有進行中的 trace 傳送作業完成,而不關閉 exporter。
shutdown「shutdown」的直接連結
async shutdown(): Promise<void>
完成所有開啟中的 trace,並 flush 待處理的傳送作業。
使用方式「使用方式」的直接連結
零設定(使用環境變數)「零設定(使用環境變數)」的直接連結
import { DeepEvalExporter } from '@mastra/deepeval'
// Reads from CONFIDENT_API_KEY, CONFIDENT_TRACE_ENVIRONMENT
const exporter = new DeepEvalExporter()
明確設定「明確設定」的直接連結
import { DeepEvalExporter } from '@mastra/deepeval'
const exporter = new DeepEvalExporter({
apiKey: process.env.CONFIDENT_API_KEY,
environment: 'production',
})
Span 類型對應「Span 類型對應」的直接連結
| Mastra span 類型 | Confident AI span 類型 |
|---|---|
AGENT_RUN, WORKFLOW_RUN | AGENT |
MODEL_GENERATION | LLM |
TOOL_CALL, MCP_TOOL_CALL, PROVIDER_TOOL_CALL, CLIENT_TOOL_CALL | TOOL |
RAG_EMBEDDING, RAG_VECTOR_OPERATION | RETRIEVER |
| 所有其他匯出的 span 類型 | CUSTOM |
事件 span(例如 MODEL_CHUNK)會被捨棄。