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

OtlpTracer unstable

Exports Effect tracing spans over OTLP/HTTP.

This module creates a Tracer.Tracer backed by the shared OTLP batch exporter, so spans created by Effect tracing APIs can be sent to an OpenTelemetry Collector, vendor endpoint, or local collector. Exported spans include identifiers, parent links, attributes, events, timing, kind, and status information. Use the constructor directly or install it through the provided layer.

6 exports Since v4.0.0 Source

Constructors

make

unstable
Since v4.0.0

Creates a Tracer that exports ended sampled spans to an OTLP traces endpoint.

Details

Spans are batched using the configured interval and batch size, serialized with OtlpSerialization, and flushed when the surrounding Scope closes.

Signature

declare const make: (options: {
readonly compression?: "gzip" | "none";
readonly context?: <X>(primitive: Tracer.EffectPrimitive<X>, span: Tracer.AnySpan) => X;
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<Tracer.Tracer, never, Exporter.Flusher | OtlpSerialization | HttpClient.HttpClient | Scope.Scope>

Layers

layer

unstable
Since v4.0.0

Provides Tracer.Tracer using the OTLP tracer created by make.

Signature

declare const layer: (options: {
readonly compression?: "gzip" | "none";
readonly context?: <X>(primitive: Tracer.EffectPrimitive<X>, span: Tracer.AnySpan) => X;
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;
}) => Layer.Layer<Exporter.Flusher, never, OtlpSerialization | HttpClient.HttpClient>
Since v4.0.0

Creates an OTLP traces layer from OpenTelemetry configuration.

Details

Compression accepts "gzip" or "none". OTEL_EXPORTER_OTLP_TRACES_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 context?: <X>(primitive: EffectPrimitive<X>, span: AnySpan) => X;
readonly headers?: Input;
readonly resource?: {
readonly attributes?: Record<string, unknown>;
readonly serviceName?: string;
readonly serviceVersion?: string;
};
}): Layer<Flusher, never, HttpClient | OtlpSerialization>

Models

ResourceSpan

interface unstable
Since v4.0.0

Group of OTLP scope spans associated with a single resource.

Signature

interface ResourceSpan {
readonly resource: Resource;
readonly schemaUrl?: string;
readonly scopeSpans: Array<ScopeSpan>;
}

ScopeSpan

interface unstable
Since v4.0.0

Group of OTLP spans emitted by a single instrumentation scope.

Signature

interface ScopeSpan {
readonly schemaUrl?: string;
readonly scope: Scope;
readonly spans: Array<OtlpSpan>;
}

TraceData

interface unstable
Since v4.0.0

Root OTLP traces payload containing spans grouped by resource.

Signature

interface TraceData {
readonly resourceSpans: Array<ResourceSpan>;
}