Skip to content

OtlpLogger

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 Added in v4.0.0 Source

Constructors

make

Added in v4.0.0 Source

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 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

Added in v4.0.0 Source

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 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>;

Creates an OTLP logs layer from OpenTelemetry configuration.

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

Added in v4.0.0 Source

OTLP logs payload serialized by OtlpLogger.

Signature

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