DeepEvalExporter
Sends Tracing data to Confident AI for evaluation and observability. Exported by @mastra/deepeval, which builds on the DeepEval SDK.
See Confident AI exporter for setup and usage.
ConstructorDirect link to Constructor
new DeepEvalExporter(config?: DeepEvalExporterConfig)
DeepEvalExporterConfigDirect link to 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
}
Extends BaseExporterConfig, which includes:
logger?: IMastraLogger- Logger instancelogLevel?: LogLevel | 'debug' | 'info' | 'warn' | 'error'- Log level (default: INFO)
apiKey?:
string
Confident AI API key. Falls back to the CONFIDENT_API_KEY env var. The exporter disables itself when no key is found.
environment?:
string
Trace environment. Falls back to CONFIDENT_TRACE_ENVIRONMENT, then 'development'.
name?:
string
Trace name applied to every trace. Defaults to the Mastra serviceName.
metadata?:
Record<string, any>
Metadata applied to every trace.
threadId?:
string
Thread ID applied to every trace. A threadId in the root span metadata overrides it per request.
userId?:
string
User ID applied to every trace. A userId in the root span metadata overrides it per request.
testCaseId?:
string
Test case ID applied to every trace. A testCaseId in the root span metadata overrides it per request.
turnId?:
string
Turn ID applied to every trace. A turnId in the root span metadata overrides it per request.
metricCollection?:
string
Trace-level metric collection.
traceMetricCollection?:
string
Trace-level metric collection. Takes precedence over metricCollection.
llmMetricCollection?:
string
Metric collection applied to LLM spans.
agentMetricCollection?:
string
Metric collection applied to agent spans.
toolMetricCollectionMap?:
Record<string, string>
Metric collection applied per tool name.
prompt?:
Prompt
Confident AI managed prompt linkage attached to LLM spans.
debug?:
boolean
Logs exporter configuration and export errors to the console.
traceCaptureSink?:
(trace: Trace) => void
Receives completed traces locally instead of posting them to Confident AI. Use for offline evaluation.
logLevel?:
'debug' | 'info' | 'warn' | 'error'
Logger level (default: 'info')
MethodsDirect link to Methods
exportTracingEventDirect link to exporttracingevent
async exportTracingEvent(event: TracingEvent): Promise<void>
Exports a tracing event to Confident AI. Builds the trace tree from the Mastra span stream and posts the trace when the root span ends.
flushDirect link to flush
async flush(): Promise<void>
Waits for any in-flight trace posts to settle without shutting down the exporter.
shutdownDirect link to shutdown
async shutdown(): Promise<void>
Finalizes any open traces and flushes pending posts.
UsageDirect link to Usage
Zero-Config (using environment variables)Direct link to Zero-Config (using environment variables)
import { DeepEvalExporter } from '@mastra/deepeval'
// Reads from CONFIDENT_API_KEY, CONFIDENT_TRACE_ENVIRONMENT
const exporter = new DeepEvalExporter()
Explicit ConfigurationDirect link to Explicit Configuration
import { DeepEvalExporter } from '@mastra/deepeval'
const exporter = new DeepEvalExporter({
apiKey: process.env.CONFIDENT_API_KEY,
environment: 'production',
})
Span type mappingDirect link to Span type mapping
| Mastra span type | Confident AI span type |
|---|---|
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 |
| All other exported span types | CUSTOM |
Event spans (for example MODEL_CHUNK) are dropped.