-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtracing.js
52 lines (41 loc) · 1.57 KB
/
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
'use strict';
const { NodeTracerProvider } = require('@opentelemetry/node');
const { registerInstrumentations } = require('@opentelemetry/instrumentation');
const { HttpInstrumentation } = require('@opentelemetry/instrumentation-http');
const { GrpcInstrumentation } = require('@opentelemetry/instrumentation-grpc');
const { Resource } = require('@opentelemetry/resources');
const { ResourceAttributes } = require('@opentelemetry/semantic-conventions');
const { ZipkinExporter } = require('@opentelemetry/exporter-zipkin');
const { MongoDBInstrumentation } = require('@opentelemetry/instrumentation-mongodb');
const { RedisInstrumentation } = require('@opentelemetry/instrumentation-redis');
const CustomSpanProcessor = require('./CustomSpanProcessor');
const config = require('./config.json');
const exporter = new ZipkinExporter({
url: `${config.endpoint}/spans`
})
const provider = new NodeTracerProvider({
resource: new Resource({
[ResourceAttributes.SERVICE_NAME]: config.serviceName,
}),
});
provider.addSpanProcessor(
new CustomSpanProcessor(exporter, {
maxQueueSize: 6000,
maxExportBatchSize: 5120,
scheduledDelayMillis: 5000,
exportTimeoutMillis: 30000
})
);
provider.register();
let dbOptions = config.dbOptions;
let options = [
new HttpInstrumentation(),
new GrpcInstrumentation(),
]
for (let prop in dbOptions) {
if (prop === "mongodb" && dbOptions[prop]) options.push(new MongoDBInstrumentation());
if (prop === "redis" && dbOptions[prop]) options.push(new RedisInstrumentation());
}
registerInstrumentations({
instrumentations: options,
});