ConsoleExporter
Outputs trace events to the console for debugging and development.
ConstructorDirect link to Constructor
new ConsoleExporter(logger?: IMastraLogger)
PropertiesDirect link to Properties
readonly name = 'tracing-console-exporter';
MethodsDirect link to Methods
exportEventDirect link to exportEvent
async exportEvent(event: AITracingEvent): Promise<void>
Exports a tracing event to the console.
shutdownDirect link to shutdown
async shutdown(): Promise<void>
Logs shutdown message.
Output FormatDirect link to Output Format
The exporter outputs different formats based on event type:
SPAN_STARTEDDirect link to SPAN_STARTED
🚀 SPAN_STARTED
Type: [span type]
Name: [span name]
ID: [span id]
Trace ID: [trace id]
Input: [formatted input]
Attributes: [formatted attributes]
────────────────────────────────────────
SPAN_ENDEDDirect link to SPAN_ENDED
✅ SPAN_ENDED
Type: [span type]
Name: [span name]
ID: [span id]
Duration: [duration]ms
Trace ID: [trace id]
Input: [formatted input]
Output: [formatted output]
Error: [formatted error if present]
Attributes: [formatted attributes]
────────────────────────────────────────
SPAN_UPDATEDDirect link to SPAN_UPDATED
📝 SPAN_UPDATED
Type: [span type]
Name: [span name]
ID: [span id]
Trace ID: [trace id]
Input: [formatted input]
Output: [formatted output]
Error: [formatted error if present]
Updated Attributes: [formatted attributes]
────────────────────────────────────────
UsageDirect link to Usage
import { ConsoleExporter } from "@mastra/core/ai-tracing";
import { ConsoleLogger, LogLevel } from "@mastra/core/logger";
// Use default logger (INFO level)
const exporter = new ConsoleExporter();
// Use custom logger
const customLogger = new ConsoleLogger({ level: LogLevel.DEBUG });
const exporterWithLogger = new ConsoleExporter(customLogger);
Implementation DetailsDirect link to Implementation Details
- Formats attributes as JSON with 2-space indentation
- Calculates and displays span duration in milliseconds
- Handles serialization errors gracefully
- Logs unimplemented event types as warnings
- Uses 80-character separator lines between events
See AlsoDirect link to See Also
DocumentationDirect link to Documentation
- AI Tracing Overview - Complete guide
- Exporters - Exporter concepts
Other ExportersDirect link to Other Exporters
- DefaultExporter - Storage persistence
- CloudExporter - Mastra Cloud
- Langfuse - Langfuse integration
- Braintrust - Braintrust integration
ReferenceDirect link to Reference
- Configuration - Configuration options
- Interfaces - Type definitions