Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | import { NodeSDK } from '@opentelemetry/sdk-node'; import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http'; import { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node'; import { Resource } from '@opentelemetry/resources'; import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions'; let sdk: NodeSDK | null = null; export async function initTracing() { Iif (sdk) { return; } const traceExporter = new OTLPTraceExporter(); sdk = new NodeSDK({ resource: new Resource({ [SemanticResourceAttributes.SERVICE_NAME]: 'repoburg-backend', }), traceExporter, instrumentations: [ getNodeAutoInstrumentations({ '@opentelemetry/instrumentation-fs': { enabled: false, }, }), ], }); try { await sdk.start(); } catch (error) { // Tracing initialization failed - continue without tracing } // Graceful shutdown process.on('SIGTERM', () => { sdk ?.shutdown() .catch(() => {}) .finally(() => process.exit(0)); }); } |