WebSdk
Browser OpenTelemetry setup for Effect applications.
This module exports a Configuration type and layers for installing tracing, metrics, and logging in browser runtimes. The main layer builds the shared OpenTelemetry resource from explicit service metadata, then enables only the signal types that have processors or readers configured. layerTracerProvider creates a scoped WebTracerProvider.
Layers
Signature
declare const layer: { (evaluate: LazyArg<Configuration>): Layer<Resource>; <E, R>(evaluate: Effect<Configuration, E, R>): Layer<Resource, E, R>;};layerTracerProvider
Added in v4.0.0
Source
Creates a scoped Web OpenTelemetry tracer provider from one or more span processors and shuts it down when the layer is released.
Signature
declare function layerTracerProvider( processor: any, config?: Omit<TracerConfig, "resource">,): Layer<OtelTracerProvider, never, Resource>;Models
Configuration interface
Added in v4.0.0
Source
Configuration for the Web OpenTelemetry layer, including resource metadata and optional tracing, metrics, and logging settings.
Signature
interface Configuration { readonly loggerMergeWithExisting?: boolean; readonly loggerProviderConfig?: Omit<LoggerProviderConfig, "resource">; readonly logRecordProcessor?: any; readonly metricReader?: any; readonly metricTemporality?: TemporalityPreference; readonly resource: { readonly attributes?: any; readonly serviceName: string; readonly serviceVersion?: string; }; readonly spanProcessor?: any; readonly tracerConfig?: Omit<TracerConfig, "resource">;}
Creates a Web OpenTelemetry layer from configuration, providing the resource and enabling tracing, metrics, and logging when configured.
When to use
Use to install browser OpenTelemetry support when service metadata is configured in code and telemetry processors or readers are supplied directly.
Details
The configuration can be provided lazily or effectfully. The layer always provides
Resource.Resource; tracing, metrics, and logging are installed only when the corresponding processors or readers are non-empty.Gotchas
Browser resource metadata is explicit; this layer does not read OpenTelemetry environment variables. Empty processor or reader arrays are treated as not configured.