-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
35 lines (24 loc) · 861 Bytes
/
app.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
const {Tracer, ExplicitContext, ConsoleRecorder} = require('zipkin');
const zipkinMiddleware = require('zipkin-instrumentation-express').expressMiddleware;
const appName = require('./app/core/constants');
var express = require('express'),
config = require('./config/config');
const ctxImpl = new ExplicitContext();
const recorder = new ConsoleRecorder();
const tracer = new Tracer({ctxImpl, recorder}); // configure your tracer properly here
var app = express();
// add the Zipkin middleware
app.use(zipkinMiddleware({
tracer,
serviceName: appName,
port: config.port,
}));
app.use((req, res, next) => {
// inject tracer into req for DI
req.tracer = tracer;
next();
});
module.exports = require('./config/express')(app, config);
app.listen(config.port, function () {
console.log('Express server listening on port ' + config.port);
});