The TracerProvider instance to use, or null to clear the isolated provider
import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node';
import { LangfuseSpanProcessor } from '@langfuse/otel';
import { setLangfuseTracerProvider } from '@langfuse/tracing';
// Create provider with span processors in constructor
const provider = new NodeTracerProvider({
spanProcessors: [new LangfuseSpanProcessor()]
});
setLangfuseTracerProvider(provider);
// Note: Spans created with getLangfuseTracer() may still inherit
// context from spans created with the global tracer
Sets an isolated TracerProvider for Langfuse tracing operations.
This allows Langfuse to use its own TracerProvider instance, separate from the global OpenTelemetry TracerProvider. This is useful for avoiding conflicts with other OpenTelemetry instrumentation in the application.
⚠️ Limitation: Span Context Sharing
While this function isolates span processing and export, it does NOT provide complete trace isolation. OpenTelemetry context (trace IDs, parent spans) is still shared between the global and isolated providers. This means:
Why this happens: OpenTelemetry uses a global context propagation mechanism that operates at the JavaScript runtime level, independent of individual TracerProvider instances. The context (containing trace ID, span ID) flows through async boundaries and is inherited by all spans created within that context, regardless of which TracerProvider creates them.