request-tracer
v0.1.5
Published
Expressjs request tracing utility
Downloads
35
Readme
request-tracer
Allows to trace HTTP/HTTPs requests in Express by appending traceIds to request header.
Usage
Install
$ npm install --save request-tracer
Example
var express = require('express');
var requestTracer = require('request-tracer');
var tracerListener = requestTracer({ router: express.Router() });
tracerListener.on('newProcess', function(traceProcessId) {
console.log('New process[%s] with configuration', traceProcessId);
});
tracerListener.on('newSession', function(id, traceProcessId) {
console.log('New session[%s] in process[%s]', id, traceProcessId);
});
tracerListener.on('newRequest', function(id, traceSessionId) {
console.log('New request[%s] in session[%s]', id, traceSessionId);
});
var app = express();
app.use(tracerListener.interceptor());
// ...
app.use(function(req, res, next) {
console.log(' - traceProcessId: %s', req.traceProcessId);
console.log(' - traceSessionId: %s', req.traceSessionId);
console.log(' - traceRequestId: %s', req.traceRequestId);
next();
});