-
Notifications
You must be signed in to change notification settings - Fork 1
/
tracing.js
20 lines (17 loc) · 1015 Bytes
/
tracing.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// adapted from:
// https://github.com/open-telemetry/opentelemetry-js/blob/main/getting-started/ts-example/README.md
// https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-exporter-collector-grpc
const { NodeTracerProvider } = require("@opentelemetry/sdk-trace-node");
const { registerInstrumentations } = require("@opentelemetry/instrumentation");
const { ExpressInstrumentation } = require("@opentelemetry/instrumentation-express");
const { HttpInstrumentation } = require("@opentelemetry/instrumentation-http");
const { SimpleSpanProcessor } = require("@opentelemetry/sdk-trace-base");
const { OTLPTraceExporter } = require("@opentelemetry/exporter-trace-otlp-grpc");
const provider = new NodeTracerProvider({});
const exporter = new OTLPTraceExporter();
provider.addSpanProcessor(new SimpleSpanProcessor(exporter));
registerInstrumentations({
tracerProvider: provider,
instrumentations: [new ExpressInstrumentation(), new HttpInstrumentation()],
});
provider.register();