-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathotlp.js
More file actions
24 lines (22 loc) · 876 Bytes
/
otlp.js
File metadata and controls
24 lines (22 loc) · 876 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const { NodeSDK } = require('@opentelemetry/sdk-node');
const { OTLPMetricExporter } = require('@opentelemetry/exporter-metrics-otlp-http');
const { PeriodicExportingMetricReader } = require('@opentelemetry/sdk-metrics');
const { getNodeAutoInstrumentations } = require('@opentelemetry/auto-instrumentations-node');
const otlpEndpoint = process.env.OTEL_EXPORTER_OTLP_ENDPOINT || 'http://otel-collector:4318';
const sdk = new NodeSDK({
metricReader: new PeriodicExportingMetricReader({
exporter: new OTLPMetricExporter({ url: `${otlpEndpoint}/v1/metrics` }),
exportIntervalMillis: 5000,
}),
instrumentations: [
getNodeAutoInstrumentations({
'@opentelemetry/instrumentation-http': {
'enabled': true,
'enhancedMetrics': true,
'tracing': false,
},
}),
],
});
sdk.start();
console.log('OpenTelemetry initialized ✅');