/** * Resilient Exporter * * Wrapper that ensures Tier 2/3 export failures never block core request paths. * Export failures are observable via metrics, not via blocking or exceptions. */ import type { SpanExporter, ReadableSpan } from "@opentelemetry/sdk-trace-base"; import { ExportResult } from "@opentelemetry/core"; /** * Configuration for the resilient exporter. */ export interface ResilientExporterConfig { /** Underlying exporter to wrap */ delegate: SpanExporter; /** Max items to buffer before dropping (default: 2048) */ maxQueueSize?: number; /** Export timeout in ms (default: 30000) */ exportTimeoutMs?: number; /** Callback when items are dropped due to backpressure */ onDrop?: (count: number, reason: "queue_full" | "export_failed" | "timeout") => void; } /** * Metrics exposed by the resilient exporter. */ export interface ResilientExporterMetrics { /** Total spans dropped due to backpressure or failure */ dropped: number; /** Current queue size */ queued: number; /** Total export failures */ failures: number; } /** * Resilient exporter wrapper that: * - Drops spans when queue is full (never blocks) * - Catches export failures and emits metrics * - Times out stalled exports * * CRITICAL: Telemetry export must be fire-and-forget from the application's perspective. * Export failures should be observable via metrics, not via blocking or exceptions. */ export declare class ResilientExporter implements SpanExporter { private readonly delegate; private readonly maxQueueSize; private readonly exportTimeoutMs; private readonly onDrop; private queuedCount; private droppedCount; private exportFailures; private shuttingDown; constructor(config: ResilientExporterConfig); /** * Export spans with resilient error handling. * * IMPORTANT: Always returns SUCCESS to caller - export failures are * observable via metrics, not via the result callback. */ export(spans: ReadableSpan[], resultCallback: (result: ExportResult) => void): void; /** * Shutdown the underlying exporter. * Marks exporter as shutting down to reject new exports. */ shutdown(): Promise; /** * Force flush the underlying exporter. */ forceFlush(): Promise; /** * Get current metrics for observability. */ getMetrics(): ResilientExporterMetrics; /** * Reset metrics (for testing). */ resetMetrics(): void; } //# sourceMappingURL=resilient-exporter.d.ts.map