11import { resourceFromAttributes } from "@opentelemetry/resources" ;
22import { NodeSDK , NodeSDKConfiguration } from "@opentelemetry/sdk-node" ;
3- import { BatchSpanProcessor } from "@opentelemetry/sdk-trace-node" ;
43import { VERSION } from "../version" ;
54import { OpenTelemetryKeys } from "./OpenTelemetryKeys" ;
65import { Tracer , TracerInitializeOptions } from "./Tracer" ;
76import { TracerConfiguration } from "./TracerConfiguration" ;
87
98export type NodeTracerInitializeOptions = TracerInitializeOptions & {
10- instrumentations ?: NodeSDKConfiguration [ "instrumentations" ] ;
119 resourceAttributes ?: Record < string , unknown > ;
12- } ;
10+ } & Partial < NodeSDKConfiguration > ;
1311
1412export class NodeTracer extends Tracer {
1513 private nodeSDK ?: NodeSDK ;
1614
1715 public async initialize (
18- options : NodeTracerInitializeOptions = { } ,
16+ options : NodeTracerInitializeOptions = { }
1917 ) : Promise < NodeTracer > {
2018 if ( this . _initialized ) {
2119 return this ;
@@ -34,7 +32,7 @@ export class NodeTracer extends Tracer {
3432 this . nodeSDK = new NodeSDK ( {
3533 resource : resourceFromAttributes ( resourceAttributes ) ,
3634 instrumentations : options . instrumentations ,
37- spanProcessor : new BatchSpanProcessor ( spanExporter ) ,
35+ traceExporter : spanExporter ,
3836 ...options ,
3937 } ) ;
4038
@@ -44,7 +42,7 @@ export class NodeTracer extends Tracer {
4442 return this ;
4543 } catch ( error ) {
4644 throw new Error (
47- `Failed to initialize node tracer: ${ error instanceof Error ? error . message : String ( error ) } ` ,
45+ `Failed to initialize node tracer: ${ error instanceof Error ? error . message : String ( error ) } `
4846 ) ;
4947 }
5048 }
@@ -66,11 +64,17 @@ export class NodeTracer extends Tracer {
6664 }
6765
6866 public static createWithConfiguration (
69- configuration : TracerConfiguration ,
67+ configuration : TracerConfiguration
7068 ) : NodeTracer {
7169 return new NodeTracer ( configuration ) ;
7270 }
7371
72+ public async forceFlush ( ) : Promise < void > {
73+ if ( this . nodeSDK ) {
74+ await this . nodeSDK . shutdown ( ) ;
75+ }
76+ }
77+
7478 public async shutdown ( ) : Promise < void > {
7579 if ( this . nodeSDK ) {
7680 await this . nodeSDK . shutdown ( ) ;
0 commit comments