OtlpExporter unstable
Shared batch exporter for OTLP/HTTP observability modules.
Signal modules use this exporter to buffer already-encoded telemetry and post it to a configured OTLP endpoint. It owns the scoped transport loop, batching, retry behavior, temporary disabling after repeated failures, and final flush during shutdown.
Constructors
Creates a scoped OTLP batch exporter.
Details
The exporter buffers pending pushed items up to maxQueueSize (dropping new
arrivals on overflow and notifying onDrop), sends FIFO batches of at most
maxBatchSize with up to concurrency exports (including retries) in flight
at a time, temporarily disables exporting after unhandled failures, and
drains remaining items during scope finalization up to shutdownTimeout.
maxQueueSize bounds only pending queued items, not batches already in
flight.
The export interval starts with the first push and stops once an export
empties the buffer, so an idle exporter keeps no timer pending. With
exportEmpty and batching disabled, it exports on every interval instead.
Optional gzip compression uses HttpClientRequest.compressBody before the
retry loop, so retries reuse the compressed bytes. Bodies smaller than 1KB
remain uncompressed. Compression requires runtime CompressionStream support;
compression failures follow the same temporary-disable behavior as transport
failures and do not fail flushing or shutdown.
Signature
declare const make: (options: { readonly body: (data: Array<any>) => readonly [body: HttpBody, onSuccess: Effect.Effect<void>]; readonly compression?: "gzip" | "none"; readonly concurrency?: Concurrency; readonly exportEmpty?: boolean; readonly exportInterval: Duration.Input; readonly headers: Headers.Input | undefined; readonly label: string; readonly maxBatchSize: number | "disabled"; readonly maxQueueSize?: number; readonly onDrop?: (count: number) => void; readonly shutdownTimeout: Duration.Input; readonly url: string;}) => Effect.Effect<{ readonly push: (data: unknown) => void;}, never, Flusher | HttpClient.HttpClient | Scope.Scope>Layers
layerFlusher
unstableProvides a Flusher backed by a fresh registry.
Details
This is intentionally a single module-level constant rather than a factory:
layer memoization is keyed by layer instance, so every signal layer
referencing this same constant shares one registry per layer build, and one
flush drains traces, logs and metrics together. A factory returning a new
layer per call would silently create one registry per signal.
Registration is scoped โ an exporter is removed from the registry when its own scope closes. Flushing with an empty registry is a no-op.
For each registered exporter, flush awaits all exports already in flight
when it was called and drains every item accepted before the call (or sends
one fresh snapshot when exportEmpty is enabled). Interrupting flush only
stops waiting and does not cancel in-flight exports or drop queued items.
Signature
declare const layerFlusher: Layer.Layer<Flusher>Services
Registry of exporter flush operations, used to manually drain buffered telemetry before the surrounding scope closes.
Details
Every exporter created by make registers its flush operation here, so a
single flush drains all signals sharing the registry concurrently while
each exporter respects its own concurrency limit. For each exporter,
flush returns once every export already in flight when it was called has
settled and every item accepted before the call has been sent or discarded by
a failed export (or after one fresh snapshot settles when exportEmpty is
enabled). flush cannot fail and respects each exporter's temporary-disable
window. Wrap it with Effect.timeoutOption to bound its duration at the call
site.
Signature
declare class Flusher extends Shape<"effect/observability/OtlpExporter/Flusher", { readonly flush: Effect<void>; readonly register: (run: Effect<void>) => Effect<void, never, Scope>;}, this> { constructor(_: never);}