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

Otlp unstable

Configures OpenTelemetry Protocol (OTLP) HTTP export for Effect telemetry.

This module installs the OTLP logger, metrics exporter, and tracer exporter from one shared configuration. Use it when an application sends logs, metrics, and traces to the same OpenTelemetry Collector, vendor OTLP endpoint, or local development collector.

4 exports Since v4.0.0 Source

Layers

layer

unstable
Since v4.0.0

Creates a combined OTLP layer for logs, metrics, and traces.

Details

The layer sends data to /v1/logs, /v1/metrics, and /v1/traces below baseUrl and requires an OtlpSerialization implementation.

Signature

declare function layer(options: {
readonly baseUrl: string;
readonly compression?: "none" | "gzip";
readonly headers?: Input;
readonly loggerExcludeLogSpans?: boolean;
readonly loggerExportInterval?: Input;
readonly loggerMergeWithExisting?: boolean;
readonly maxBatchSize?: number;
readonly metricsExportInterval?: Input;
readonly metricsTemporality?: AggregationTemporality;
readonly resource?: {
readonly attributes?: Record<string, unknown>;
readonly serviceName?: string;
readonly serviceVersion?: string;
};
readonly shutdownTimeout?: Input;
readonly tracerContext?: <X>(primitive: EffectPrimitive<X>, span: AnySpan) => X;
readonly tracerExportInterval?: Input;
}): Layer<never, never, HttpClient | OtlpSerialization>
Since v4.0.0

Creates a combined OTLP layer for logs, metrics, and traces from OpenTelemetry configuration.

Signature

declare function layerFromConfig(options?: {
readonly headers?: Input;
readonly loggerExcludeLogSpans?: boolean;
readonly loggerMergeWithExisting?: boolean;
readonly resource?: {
readonly attributes?: Record<string, unknown>;
readonly serviceName?: string;
readonly serviceVersion?: string;
};
readonly tracerContext?: <X>(primitive: EffectPrimitive<X>, span: AnySpan) => X;
}): Layer<never, never, HttpClient | OtlpSerialization>

layerJson

unstable
Since v4.0.0

Creates the combined OTLP logs, metrics, and traces layer using JSON serialization.

Signature

declare const layerJson: (options: {
readonly baseUrl: string;
readonly compression?: "gzip" | "none";
readonly headers?: Headers.Input;
readonly loggerExcludeLogSpans?: boolean;
readonly loggerExportInterval?: Duration.Input;
readonly loggerMergeWithExisting?: boolean;
readonly maxBatchSize?: number;
readonly metricsExportInterval?: Duration.Input;
readonly metricsTemporality?: AggregationTemporality;
readonly resource?: {
readonly attributes?: Record<string, unknown>;
readonly serviceName?: string;
readonly serviceVersion?: string;
};
readonly shutdownTimeout?: Duration.Input;
readonly tracerContext?: <X>(primitive: Tracer.EffectPrimitive<X>, span: Tracer.AnySpan) => X;
readonly tracerExportInterval?: Duration.Input;
}) => Layer.Layer<never, never, HttpClient.HttpClient>
Since v4.0.0

Creates the combined OTLP logs, metrics, and traces layer using protobuf serialization.

Signature

declare const layerProtobuf: (options: {
readonly baseUrl: string;
readonly compression?: "gzip" | "none";
readonly headers?: Headers.Input;
readonly loggerExcludeLogSpans?: boolean;
readonly loggerExportInterval?: Duration.Input;
readonly loggerMergeWithExisting?: boolean;
readonly maxBatchSize?: number;
readonly metricsExportInterval?: Duration.Input;
readonly metricsTemporality?: AggregationTemporality;
readonly resource?: {
readonly attributes?: Record<string, unknown>;
readonly serviceName?: string;
readonly serviceVersion?: string;
};
readonly shutdownTimeout?: Duration.Input;
readonly tracerContext?: <X>(primitive: Tracer.EffectPrimitive<X>, span: Tracer.AnySpan) => X;
readonly tracerExportInterval?: Duration.Input;
}) => Layer.Layer<never, never, HttpClient.HttpClient>