forked from GoogleCloudPlatform/microservices-demo
-
Notifications
You must be signed in to change notification settings - Fork 30
/
tracing.js
29 lines (24 loc) · 1017 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
27
28
29
const { NodeTracerProvider } = require('@opentelemetry/node');
const { B3MultiPropagator } = require('@opentelemetry/propagator-b3');
const { ZipkinExporter } = require('@opentelemetry/exporter-zipkin');
const { GrpcInstrumentation } = require('@opentelemetry/instrumentation-grpc');
const { BatchSpanProcessor, ConsoleSpanExporter } = require('@opentelemetry/tracing');
const { registerInstrumentations } = require('@opentelemetry/instrumentation');
const provider = new NodeTracerProvider();
provider.register({
propagator: new B3MultiPropagator(),
});
registerInstrumentations({
instrumentations: [
new GrpcInstrumentation(),
],
});
const exporter = new ZipkinExporter({
serviceName: 'paymentservice',
url: process.env.SIGNALFX_ENDPOINT_URL,
});
provider.addSpanProcessor(new BatchSpanProcessor(exporter));
const CONSOLE_SPAN = process.env['CONSOLE_SPAN'];
if (CONSOLE_SPAN === 'true') {
provider.addSpanProcessor(new BatchSpanProcessor(new ConsoleSpanExporter(), { bufferTimeout: 1000 }));
}