/** * CLS Flusher — uploads CLS spans to Tencent Cloud CLS via tencentcloud-cls-sdk-js. * * Batched upload with configurable batch size and flush interval. * Error handling: 4xx discards (non-retryable), 5xx uses SDK built-in retry. * * Span content is never modified here. `maxBatchBytes` only decides how spans are * grouped into requests; keeping captured content byte-exact is the upstream * `contentMaxChars` limit's job. */ import type { CLSSpan } from './cls-types.js'; import type { ResolvedClsConfig } from './config.js'; import type { DshLogger } from './dsh-types.js'; export declare class CLSFlusher { private readonly config; private readonly logger; private client; private queue; private flushTimer; /** In-flight drain, so concurrent flushes join it rather than being skipped. */ private inFlight; private sentCount; private failedCount; private droppedCount; private oversizeCount; constructor(config: ResolvedClsConfig, logger: DshLogger); /** Initialize CLS client and start periodic flushing. */ start(): void; /** Enqueue a span for upload. Drops oldest spans when queue exceeds maxQueueSize. */ enqueue(span: CLSSpan): void; /** Enqueue multiple spans. */ enqueueBatch(spans: CLSSpan[]): void; /** * Flush queued spans to CLS. * * Concurrent callers join the in-flight run instead of being dropped. Dropping * meant a timer tick could silently skip a flush, and during shutdown there is * no later tick to make up for it. */ flush(): Promise; /** Drain the queue in byte-bounded batches. Never throws; failures are logged. */ private drain; /** * Stop periodic flushing and drain whatever is still queued. * * `flush` joins an in-flight drain instead of returning early, so the final * batch is no longer discarded when shutdown races an ongoing flush. Repeating * only covers spans enqueued while a drain was running; the loop gives up if an * attempt makes no progress, so a permanently failing send cannot spin here. */ stop(): Promise; private estimateSpanBytes; /** Identify a span in diagnostics without emitting captured content. */ private describeSpan; /** * Warn that a span exceeds the per-batch byte budget. * * The span is still uploaded unmodified. CLS may reject it, but a rejection is * visible in the logs, whereas silently truncated content would be * indistinguishable from a genuinely short prompt during analysis. */ private reportOversize; private send; } //# sourceMappingURL=cls-flusher.d.ts.map