Skip to content

OtlpTracer.ts

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.

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 url: string
readonly resource?:
| {
readonly serviceName?: string | undefined
readonly serviceVersion?: string | undefined
readonly attributes?: Record<string, unknown>
}
| undefined
readonly headers?: Headers.Input | undefined
readonly exportInterval?: Duration.Input | undefined
readonly maxBatchSize?: number | undefined
readonly context?: (<X>(primitive: Tracer.EffectPrimitive<X>, span: Tracer.AnySpan) => X) | undefined
readonly shutdownTimeout?: Duration.Input | undefined
}) => Effect.Effect<Tracer.Tracer, never, OtlpSerialization | HttpClient.HttpClient | Scope.Scope>

Source

Since v4.0.0

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

Signature

declare const layer: (options: {
readonly url: string
readonly resource?:
| {
readonly serviceName?: string | undefined
readonly serviceVersion?: string | undefined
readonly attributes?: Record<string, unknown>
}
| undefined
readonly headers?: Headers.Input | undefined
readonly exportInterval?: Duration.Input | undefined
readonly maxBatchSize?: number | undefined
readonly context?: (<X>(primitive: Tracer.EffectPrimitive<X>, span: Tracer.AnySpan) => X) | undefined
readonly shutdownTimeout?: Duration.Input | undefined
}) => Layer.Layer<never, never, OtlpSerialization | HttpClient.HttpClient>

Source

Since v4.0.0

Creates an OTLP traces layer from OpenTelemetry configuration.

Signature

declare const layerFromConfig: (options?: {
readonly resource?:
| {
readonly serviceName?: string | undefined
readonly serviceVersion?: string | undefined
readonly attributes?: Record<string, unknown>
}
| undefined
readonly headers?: Headers.Input | undefined
readonly context?: (<X>(primitive: Tracer.EffectPrimitive<X>, span: Tracer.AnySpan) => X) | undefined
}) => Layer.Layer<never, never, HttpClient.HttpClient | OtlpSerialization>

Source

Since v4.0.0

Group of OTLP scope spans associated with a single resource.

Signature

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

Source

Since v4.0.0

Group of OTLP spans emitted by a single instrumentation scope.

Signature

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

Source

Since v4.0.0

Root OTLP traces payload containing spans grouped by resource.

Signature

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

Source

Since v4.0.0