Skip to content

OtlpTracer

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

Constructors

make

Added in v4.0.0 Source

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

Added in v4.0.0 Source

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

Signature

declare const layer: (options: {
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>;

Creates an OTLP traces layer from OpenTelemetry configuration.

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

Added in v4.0.0 Source

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

Added in v4.0.0 Source

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

Added in v4.0.0 Source

Root OTLP traces payload containing spans grouped by resource.

Signature

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