-
Notifications
You must be signed in to change notification settings - Fork 4
/
tracing.js
26 lines (22 loc) · 909 Bytes
/
tracing.js
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
const process = require('process');
const { NodeSDK, logs, tracing } = require('@opentelemetry/sdk-node');
const { getNodeAutoInstrumentations } = require('@opentelemetry/auto-instrumentations-node');
const { OTLPTraceExporter } = require('@opentelemetry/exporter-trace-otlp-grpc');
const { OTLPLogExporter } = require('@opentelemetry/exporter-logs-otlp-grpc');
const sdk = new NodeSDK({
spanProcessor: new tracing.SimpleSpanProcessor(new OTLPTraceExporter()),
logRecordProcessor: new logs.SimpleLogRecordProcessor(new OTLPLogExporter()),
instrumentations: [getNodeAutoInstrumentations({
'@opentelemetry/instrumentation-fs': {
enabled: false,
},
})],
});
sdk.start();
process.on('SIGTERM', () => {
sdk
.shutdown()
.then(() => console.log('Tracing terminated'))
.catch((error) => console.log('Error terminating tracing', error))
.finally(() => process.exit(0));
});