import type { AnyExportedSpan, ObservabilityEvent } from '@mastra/core/observability';
import type { CreateSpanRecord, ObservabilityStorageStrategy, UpdateSpanRecord } from '@mastra/core/storage';
/** Mixin interface that tracks how many times a buffered event has been retried. */
export interface RetryCount {
    retryCount: number;
}
/** A partial span update record keyed by trace and span ID. */
export interface UpdateSpanPartial {
    traceId: string;
    spanId: string;
    updates: Partial<UpdateSpanRecord>;
}
/** An observability event augmented with retry tracking for the buffer. */
export type BufferedEvent = ObservabilityEvent & RetryCount;
/**
 * Buffers observability events (creates and updates) for batch flushing.
 * Handles strategy-aware routing of tracing events and tracks created spans
 * so updates can be deferred until their parent create has been flushed.
 */
export declare class EventBuffer {
    #private;
    constructor(args: {
        maxRetries: number;
    });
    /** Initialize with a storage strategy and replay any pre-init events. */
    init(args: {
        strategy: ObservabilityStorageStrategy;
    }): void;
    /** Clear the create and update buffers and reset the event timer. */
    reset(): void;
    private setFirstEventTime;
    private pushCreate;
    private pushUpdate;
    /** Route an event to the create or update buffer based on its type and the storage strategy. */
    addEvent(event: ObservabilityEvent): void;
    /** Re-add failed create events to the buffer, returning events that exceed max retries. */
    reAddCreates(events: BufferedEvent[]): BufferedEvent[];
    /** Re-add failed update events to the buffer, returning events that exceed max retries. */
    reAddUpdates(events: BufferedEvent[]): BufferedEvent[];
    /** Snapshot of buffered create events. */
    get creates(): BufferedEvent[];
    /** Snapshot of buffered update events. */
    get updates(): BufferedEvent[];
    /** Total number of buffered events (creates + updates). */
    get totalSize(): number;
    /** Milliseconds since the first event was buffered in the current batch. */
    get elapsed(): number;
    /**
     * Builds a unique span key for tracking
     */
    private buildSpanKey;
    /** Track successfully created spans so updates can verify span existence before flushing. */
    addCreatedSpans(args: {
        records: CreateSpanRecord[];
    }): void;
    /** Check whether a span's create record has already been flushed to storage. */
    spanExists(span: AnyExportedSpan): boolean;
    /** Remove completed spans from tracking after their SPAN_ENDED updates are flushed. */
    endFinishedSpans(args: {
        records: UpdateSpanPartial[];
    }): void;
}
//# sourceMappingURL=event-buffer.d.ts.map