Skip to main content

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.

Constructor
Direct link to Constructor

new DeepEvalExporter(config?: DeepEvalExporterConfig)

DeepEvalExporterConfig
Direct 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 instance
  • logLevel?: 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.

tags?:

string[]
Tags applied to every trace.

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')

Methods
Direct link to Methods

exportTracingEvent
Direct 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.

flush
Direct link to flush

async flush(): Promise<void>

Waits for any in-flight trace posts to settle without shutting down the exporter.

shutdown
Direct link to shutdown

async shutdown(): Promise<void>

Finalizes any open traces and flushes pending posts.

Usage
Direct 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 Configuration
Direct link to Explicit Configuration

import { DeepEvalExporter } from '@mastra/deepeval'

const exporter = new DeepEvalExporter({
apiKey: process.env.CONFIDENT_API_KEY,
environment: 'production',
})

Span type mapping
Direct link to Span type mapping

Mastra span typeConfident AI span type
AGENT_RUN, WORKFLOW_RUNAGENT
MODEL_GENERATIONLLM
TOOL_CALL, MCP_TOOL_CALL, PROVIDER_TOOL_CALL, CLIENT_TOOL_CALLTOOL
RAG_EMBEDDING, RAG_VECTOR_OPERATIONRETRIEVER
All other exported span typesCUSTOM

Event spans (for example MODEL_CHUNK) are dropped.