20 lines
716 B
TypeScript
20 lines
716 B
TypeScript
// 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)));
|
|
}
|