@mastra/core
Version:
Mastra is a framework for building AI-powered applications and agents with a modern TypeScript stack.
98 lines • 2.92 kB
TypeScript
import type { IMastraLogger } from '../../logger/index.js';
import type { Mastra } from '../../mastra/index.js';
import type { AITracingEvent, AITracingExporter, TracingConfig, TracingStrategy } from '../types.js';
interface BatchingConfig {
maxBatchSize?: number;
maxBufferSize?: number;
maxBatchWaitMs?: number;
maxRetries?: number;
retryDelayMs?: number;
strategy?: TracingStrategy | 'auto';
}
export declare class DefaultExporter implements AITracingExporter {
name: string;
private logger;
private mastra;
private config;
private resolvedStrategy;
private buffer;
private flushTimer;
private allCreatedSpans;
constructor(config?: BatchingConfig, logger?: IMastraLogger);
private strategyInitialized;
/**
* Register the Mastra instance (called after Mastra construction is complete)
*/
__registerMastra(mastra: Mastra): void;
/**
* Initialize the exporter (called after all dependencies are ready)
*/
init(_config?: TracingConfig): void;
/**
* Initialize the resolved strategy once storage is available
*/
private initializeStrategy;
/**
* Builds a unique span key for tracking
*/
private buildSpanKey;
/**
* Gets the next sequence number for a span
*/
private getNextSequence;
/**
* Handles out-of-order span updates by logging and skipping
*/
private handleOutOfOrderUpdate;
/**
* Adds an event to the appropriate buffer based on strategy
*/
private addToBuffer;
/**
* Checks if buffer should be flushed based on size or time triggers
*/
private shouldFlush;
/**
* Resets the buffer after successful flush
*/
private resetBuffer;
/**
* Schedules a flush using setTimeout
*/
private scheduleFlush;
/**
* Serializes span attributes to storage record format
* Handles all AI span types and their specific attributes
*/
private serializeAttributes;
private buildCreateRecord;
private buildUpdateRecord;
/**
* Handles realtime strategy - processes each event immediately
*/
private handleRealtimeEvent;
/**
* Handles batch-with-updates strategy - buffers events and processes in batches
*/
private handleBatchWithUpdatesEvent;
/**
* Handles insert-only strategy - only processes SPAN_ENDED events in batches
*/
private handleInsertOnlyEvent;
/**
* Calculates retry delay using exponential backoff
*/
private calculateRetryDelay;
/**
* Flushes the current buffer to storage with retry logic
*/
private flush;
/**
* Attempts to flush with exponential backoff retry logic
*/
private flushWithRetries;
exportEvent(event: AITracingEvent): Promise<void>;
shutdown(): Promise<void>;
}
export {};
//# sourceMappingURL=default.d.ts.map