Skip to content
Effect 4.0 is here. One ecosystem. Zero dependencies.

OtlpLogger unstable

Exports Effect log entries over OTLP/HTTP.

The logger turns Effect log entries into OTLP log records and sends them to a logs endpoint, such as an OpenTelemetry Collector or vendor OTLP endpoint. It includes log levels, messages, annotations, causes, fiber ids, optional log spans, and current trace/span ids when they are present.

4 exports Since v4.0.0 Source

Constructors

make

unstable
Since v4.0.0

Creates an Effect Logger that exports log records through OTLP.

Details

The logger serializes records with the configured resource, sends them through the OTLP exporter, and requires Scope so pending records can be flushed on shutdown.

Signature

declare const make: (options: {
readonly compression?: "gzip" | "none";
readonly excludeLogSpans?: boolean;
readonly exportInterval?: Duration.Input;
readonly headers?: Headers.Input;
readonly maxBatchSize?: number;
readonly resource?: {
readonly attributes?: Record<string, unknown>;
readonly serviceName?: string;
readonly serviceVersion?: string;
};
readonly shutdownTimeout?: Duration.Input;
readonly url: string;
}) => Effect.Effect<Logger.Logger<unknown, void>, never, Exporter.Flusher | OtlpSerialization | HttpClient.HttpClient | Scope.Scope>

Layers

layer

unstable
Since v4.0.0

Layer that installs the OTLP logger created by make.

Details

By default the OTLP logger is merged with any existing loggers.

Signature

declare function layer(options: {
readonly compression?: "none" | "gzip";
readonly excludeLogSpans?: boolean;
readonly exportInterval?: Input;
readonly headers?: Input;
readonly maxBatchSize?: number;
readonly mergeWithExisting?: boolean;
readonly resource?: {
readonly attributes?: Record<string, unknown>;
readonly serviceName?: string;
readonly serviceVersion?: string;
};
readonly shutdownTimeout?: Input;
readonly url: string;
}): Layer<Flusher, never, HttpClient | OtlpSerialization>
Since v4.0.0

Creates an OTLP logs layer from OpenTelemetry configuration.

Details

Compression accepts "gzip" or "none". OTEL_EXPORTER_OTLP_LOGS_COMPRESSION takes precedence over OTEL_EXPORTER_OTLP_COMPRESSION, defaulting to "none". Gzip uses HttpClientRequest's default minimum body size of 1KB.

Signature

declare function layerFromConfig(options?: {
readonly excludeLogSpans?: boolean;
readonly headers?: Input;
readonly mergeWithExisting?: boolean;
readonly resource?: {
readonly attributes?: Record<string, unknown>;
readonly serviceName?: string;
readonly serviceVersion?: string;
};
}): Layer<Flusher, never, HttpClient | OtlpSerialization>

Models

LogsData

interface unstable
Since v4.0.0

OTLP logs payload serialized by OtlpLogger.

Signature

interface LogsData {
resourceLogs: readonly Array<IResourceLogs>;
}