Skip to content

Tracer

17 exports Added in v1.0.0 Source

Accessors

Get the current OpenTelemetry span.

Works with both the official OpenTelemetry API (via Tracer.layer, NodeSdk.layer, etc.) and the lightweight OTLP module (OtlpTracer.layer).

When using OTLP, the returned span is a wrapper that conforms to the OpenTelemetry Span interface.

Signature

declare const currentOtelSpan: Effect<Otel.Span, NoSuchElementException>;

Constructors

make

Added in v1.0.0 Source

Signature

declare const make: Effect<EffectTracer, never, OtelTracer>;

Signature

declare const makeExternalSpan: (options: {
  readonly spanId: string;
  readonly traceFlags?: number;
  readonly traceId: string;
  readonly traceState?: string | Otel.TraceState;
}) => ExternalSpan;

Layers

layer

Added in v1.0.0 Source

Signature

declare const layer: Layer<OtelTracer, never, Resource | OtelTracerProvider>;

layerGlobal

Added in v1.0.0 Source

Signature

declare const layerGlobal: Layer<OtelTracer, never, Resource>;

Signature

declare const layerGlobalTracer: Layer<OtelTracer, never, Resource>;

layerTracer

Added in v1.0.0 Source

Signature

declare const layerTracer: Layer<OtelTracer, never, Resource | OtelTracerProvider>;

Signature

declare const layerWithoutOtelTracer: Layer<never, never, OtelTracer>;

Propagation

Set the effect's parent span from the given opentelemetry SpanContext.

This is handy when you set up OpenTelemetry outside of Effect and want to attach to a parent span.

Signature

declare const withSpanContext: {
  (
    spanContext: SpanContext,
  ): <A, E, R>(effect: Effect<A, E, R>) => Effect<A, E, Exclude<R, ParentSpan>>;
  <A, E, R>(
    effect: Effect<A, E, R>,
    spanContext: SpanContext,
  ): Effect<A, E, Exclude<R, ParentSpan>>;
};

Tags

Signature

declare const OtelTraceFlags: Tag<OtelTraceFlags, TraceFlags>;

OtelTraceFlags interface

Added in v1.0.0 Source

Signature

interface OtelTraceFlags {
  readonly _: typeof _;
}

OtelTracer

Added in v1.0.0 Source

Signature

declare const OtelTracer: Tag<OtelTracer, Tracer>;

OtelTracer interface

Added in v1.0.0 Source

Signature

interface OtelTracer {
  readonly _: typeof _;
}

Signature

declare const OtelTracerProvider: Tag<OtelTracerProvider, TracerProvider>;

OtelTracerProvider interface

Added in v1.0.0 Source

Signature

interface OtelTracerProvider {
  readonly _: typeof _;
}

Signature

declare const OtelTraceState: Tag<OtelTraceState, TraceState>;

OtelTraceState interface

Added in v1.0.0 Source

Signature

interface OtelTraceState {
  readonly _: typeof _;
}