11import { resourceFromAttributes } from "@opentelemetry/resources" ;
22import { NodeSDK , NodeSDKConfiguration } from "@opentelemetry/sdk-node" ;
3- import { BatchSpanProcessor } from "@opentelemetry/sdk-trace-node " ;
3+ import { Logger } from "../utils/logger " ;
44import { VERSION } from "../version" ;
55import { OpenTelemetryKeys } from "./OpenTelemetryKeys" ;
66import { Tracer , TracerInitializeOptions } from "./Tracer" ;
77import { TracerConfiguration } from "./TracerConfiguration" ;
88
99export type NodeTracerInitializeOptions = TracerInitializeOptions & {
10- instrumentations ?: NodeSDKConfiguration [ "instrumentations" ] ;
1110 resourceAttributes ?: Record < string , unknown > ;
12- } ;
11+ } & Partial < NodeSDKConfiguration > ;
1312
1413export class NodeTracer extends Tracer {
1514 private nodeSDK ?: NodeSDK ;
@@ -34,7 +33,7 @@ export class NodeTracer extends Tracer {
3433 this . nodeSDK = new NodeSDK ( {
3534 resource : resourceFromAttributes ( resourceAttributes ) ,
3635 instrumentations : options . instrumentations ,
37- spanProcessor : new BatchSpanProcessor ( spanExporter ) ,
36+ traceExporter : spanExporter ,
3837 ...options ,
3938 } ) ;
4039
@@ -72,8 +71,10 @@ export class NodeTracer extends Tracer {
7271 }
7372
7473 public async shutdown ( ) : Promise < void > {
75- if ( this . nodeSDK ) {
76- await this . nodeSDK . shutdown ( ) ;
74+ if ( ! this . nodeSDK ) {
75+ Logger . warn ( "Node SDK not initialized, skipping shutdown" ) ;
76+ return ;
7777 }
78+ await this . nodeSDK . shutdown ( ) ;
7879 }
7980}
0 commit comments