11import { resourceFromAttributes } from "@opentelemetry/resources" ;
22import { NodeSDK , NodeSDKConfiguration } from "@opentelemetry/sdk-node" ;
3+ import { BatchSpanProcessor } from "@opentelemetry/sdk-trace-node" ;
34import { VERSION } from "../version" ;
45import { OpenTelemetryKeys } from "./OpenTelemetryKeys" ;
56import { Tracer , TracerInitializeOptions } from "./Tracer" ;
@@ -14,7 +15,7 @@ export class NodeTracer extends Tracer {
1415 private nodeSDK ?: NodeSDK ;
1516
1617 public async initialize (
17- options : NodeTracerInitializeOptions = { }
18+ options : NodeTracerInitializeOptions = { } ,
1819 ) : Promise < NodeTracer > {
1920 if ( this . _initialized ) {
2021 return this ;
@@ -28,9 +29,12 @@ export class NodeTracer extends Tracer {
2829 ...options . resourceAttributes ,
2930 } ;
3031
32+ const spanExporter = await this . getSpanExporter ( ) ;
33+
3134 this . nodeSDK = new NodeSDK ( {
3235 resource : resourceFromAttributes ( resourceAttributes ) ,
3336 instrumentations : options . instrumentations ,
37+ spanProcessor : new BatchSpanProcessor ( spanExporter ) ,
3438 ...options ,
3539 } ) ;
3640
@@ -40,7 +44,7 @@ export class NodeTracer extends Tracer {
4044 return this ;
4145 } catch ( error ) {
4246 throw new Error (
43- `Failed to initialize node tracer: ${ error instanceof Error ? error . message : String ( error ) } `
47+ `Failed to initialize node tracer: ${ error instanceof Error ? error . message : String ( error ) } ` ,
4448 ) ;
4549 }
4650 }
@@ -62,7 +66,7 @@ export class NodeTracer extends Tracer {
6266 }
6367
6468 public static createWithConfiguration (
65- configuration : TracerConfiguration
69+ configuration : TracerConfiguration ,
6670 ) : NodeTracer {
6771 return new NodeTracer ( configuration ) ;
6872 }
0 commit comments