OtlpTracer.ts
OtlpTracer.ts overview
Section titled “OtlpTracer.ts overview”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
Exports Grouped by Category
Section titled “Exports Grouped by Category”constructors
Section titled “constructors”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>Since v4.0.0
layers
Section titled “layers”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>Since v4.0.0
layerFromConfig
Section titled “layerFromConfig”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>Since v4.0.0
models
Section titled “models”ResourceSpan (interface)
Section titled “ResourceSpan (interface)”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}Since v4.0.0
ScopeSpan (interface)
Section titled “ScopeSpan (interface)”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}Since v4.0.0
TraceData (interface)
Section titled “TraceData (interface)”Root OTLP traces payload containing spans grouped by resource.
Signature
export interface TraceData { readonly resourceSpans: Array<ResourceSpan>}Since v4.0.0