@@ -15,7 +15,12 @@ import {
1515 BatchSpanProcessor ,
1616 RandomIdGenerator ,
1717} from "@opentelemetry/sdk-trace-base" ;
18- import { metrics , diag , DiagConsoleLogger , DiagLogLevel } from "@opentelemetry/api" ;
18+ import {
19+ metrics ,
20+ diag ,
21+ DiagConsoleLogger ,
22+ DiagLogLevel ,
23+ } from "@opentelemetry/api" ;
1924import { logs } from "@opentelemetry/api-logs" ;
2025import { registerInstrumentations } from "@opentelemetry/instrumentation/build/src/autoLoader" ;
2126import {
@@ -72,7 +77,7 @@ export class Sdk {
7277 private meterProvider : MeterProvider | undefined ;
7378 private disableInstrumentations : ( ( ) => void ) | undefined ;
7479
75- public constructor ( private configuration : Configuration = { } ) { }
80+ public constructor ( private configuration : Configuration = { } ) { }
7681
7782 public start ( ) : void {
7883 const env = getEnv ( ) ;
@@ -278,7 +283,8 @@ function parsePropagators(
278283) : TextMapPropagator [ ] {
279284 const envPropagators =
280285 process . env . OTEL_PROPAGATORS &&
281- env . OTEL_PROPAGATORS && env . OTEL_PROPAGATORS . length > 0
286+ env . OTEL_PROPAGATORS &&
287+ env . OTEL_PROPAGATORS . length > 0
282288 ? env . OTEL_PROPAGATORS
283289 : undefined ;
284290 return ( arg ?? envPropagators ?? [ "auto" ] )
@@ -296,6 +302,10 @@ function parsePropagators(
296302 name : "baggage" ,
297303 propagator : new W3CBaggagePropagator ( ) ,
298304 } ) ;
305+ autoList . push ( {
306+ name : "vercel-runtime" ,
307+ propagator : new VercelRuntimePropagator ( ) ,
308+ } ) ;
299309
300310 diag . debug (
301311 `@vercel/otel: Configure propagators: ${ autoList
@@ -304,10 +314,6 @@ function parsePropagators(
304314 ) ;
305315 return autoList . map ( ( i ) => i . propagator ) ;
306316 }
307- if ( propagatorOrName === "experimental-vercel-trace" ) {
308- diag . debug ( "@vercel/otel: Configure propagator: vercel-runtime" ) ;
309- return new VercelRuntimePropagator ( ) ;
310- }
311317 if ( propagatorOrName === "tracecontext" ) {
312318 diag . debug ( "@vercel/otel: Configure propagator: tracecontext" ) ;
313319 return new W3CTraceContextPropagator ( ) ;
@@ -411,8 +417,12 @@ function parseSpanProcessor(
411417) : SpanProcessor [ ] {
412418 return [
413419 ...( arg ?? [ "auto" ] )
414- . map ( ( spanProcessorOrName ) => {
420+ . flatMap ( ( spanProcessorOrName ) => {
415421 if ( spanProcessorOrName === "auto" ) {
422+ const processors : SpanProcessor [ ] = [
423+ new BatchSpanProcessor ( new VercelRuntimeSpanExporter ( ) ) ,
424+ ] ;
425+
416426 if ( process . env . VERCEL_OTEL_ENDPOINTS ) {
417427 // OTEL collector is configured on 4318 port.
418428 const port = process . env . VERCEL_OTEL_ENDPOINTS_PORT || "4318" ;
@@ -433,11 +443,12 @@ function parseSpanProcessor(
433443 protocol === "http/protobuf"
434444 ? new OTLPHttpProtoTraceExporter ( config )
435445 : new OTLPHttpJsonTraceExporter ( config ) ;
436- return new BatchSpanProcessor ( exporter ) ;
446+
447+ processors . push ( new BatchSpanProcessor ( exporter ) ) ;
437448 }
438449
439450 // Consider going throw `VERCEL_OTEL_ENDPOINTS` (otel collector) for OTLP.
440- if (
451+ else if (
441452 ! configuration . traceExporter ||
442453 configuration . traceExporter === "auto" ||
443454 env . OTEL_EXPORTER_OTLP_TRACES_ENDPOINT ||
@@ -446,10 +457,7 @@ function parseSpanProcessor(
446457 return new BatchSpanProcessor ( parseTraceExporter ( env ) ) ;
447458 }
448459
449- return undefined ;
450- } else if ( spanProcessorOrName === 'experimental-vercel-trace' ) {
451- diag . debug ( "@vercel/otel: Configure vercel-runtime exporter" ) ;
452- return new BatchSpanProcessor ( new VercelRuntimeSpanExporter ( ) ) ;
460+ return processors ;
453461 }
454462 return spanProcessorOrName ;
455463 } )
0 commit comments