The tracer provider to use
Optional options: SetTracerProviderOptionsOptional provider configuration
SDK 2.x providers accept span processors only at construction time, so the provider must be built around a processor whose targets can grow later (FanoutSpanProcessor). The built-in cloud exporter is SDK 2.x and is attached through the fanout automatically.
import { telemetry } from '@livekit/agents';
import { BatchSpanProcessor, NodeTracerProvider } from '@opentelemetry/sdk-trace-node';
const fanout = new telemetry.FanoutSpanProcessor();
const provider = new NodeTracerProvider({
spanProcessors: [new BatchSpanProcessor(myBackendExporter), fanout],
});
provider.register();
telemetry.setTracerProvider(provider, {
metadata: { room_id: 'room123', job_id: 'job456' },
registerSpanProcessor: (processor) => fanout.add(processor),
});
Set the tracer provider for the livekit-agents framework. This should be called before agent session start if using custom tracer providers.