SonarQ test on PR #1
19
src/tracing.ts
Normal file
19
src/tracing.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
// OTel SDK bootstrap — loaded via --require ./dist/tracing.js before the app.
|
||||
// Auto-configures from OTEL_* env vars set in score.yaml / Humanitec.
|
||||
// No-ops gracefully when OTEL_EXPORTER_OTLP_ENDPOINT is absent (local dev).
|
||||
import { NodeSDK } from '@opentelemetry/sdk-node';
|
||||
import { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node';
|
||||
|
||||
const endpoint = process.env.OTEL_EXPORTER_OTLP_ENDPOINT;
|
||||
if (endpoint) {
|
||||
const sdk = new NodeSDK({
|
||||
instrumentations: [
|
||||
getNodeAutoInstrumentations({
|
||||
'@opentelemetry/instrumentation-fs': { enabled: false },
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
sdk.start();
|
||||
process.on('SIGTERM', () => sdk.shutdown().finally(() => process.exit(0)));
|
||||
}
|
||||
Reference in New Issue
Block a user