import { CompositePropagator } from '@opentelemetry/core' ; import { JaegerExporter } from '@opentelemetry/exporter-jaeger' ; import { ZipkinExporter } from '@opentelemetry/exporter-zipkin' ; import { JaegerPropagator } from '@opentelemetry/propagator-jaeger' ; import { Resource } from '@opentelemetry/resources' ; import { NodeSDK } from '@opentelemetry/sdk-node' ; import { AsyncLocalStorageContextManager } from '@opentelemetry/context-async-hooks' ; import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions' ; import process from 'process' ; import { BatchSpanProcessor } from '@opentelemetry/sdk-trace-base' ; const otelSDK = new NodeSDK ( { spanProcessor : new BatchSpanProcessor ( new JaegerExporter ( { endpoint : 'http://101.34.66.96:14268/api/traces' , } ) ) , resource : new Resource ( { [ SemanticResourceAttributes . SERVICE_NAME ] : 'nest-shop' , } ) , contextManager : new AsyncLocalStorageContextManager ( ) , textMapPropagator : new CompositePropagator ( { propagators : [ new JaegerPropagator ( 'nest-shop-trace-id' ) ] , } ) , } ) ; export default otelSDK ; process . on ( 'SIGINT' , ( ) => { otelSDK . shutdown ( ) . then ( ( ) => console . log ( 'SDK shut down successfully' ) , ( err ) => console . log ( 'Error shutting down SDK' , err ) ) . finally ( ( ) => process . exit ( 0 ) ) ; } ) ;