Note: This project has been moved here https://github.com/Prasanna-sr/Audit-Logger

Instrumentation

Build Status

Dependencies

Coverage Status

Provides instrumentation for express or connect middleware specific node.js applications. It helps to capture time taken for each middleware and routes.

Why

When running in production, you may wish you could have certain data avaialble for certain request. It is not efficient to log all parameters for all requests. This library helps you to create application specific rules and provides all application data only when the application fails certain rules.

Install npm version

$ npm install Instrumentation

How to use

Initialize your application by requiring the module and calling the constructor with the application object. The timers are made avaialble through req.timers, which can be grabbed anytime during the request period. req.timers is an array containing response time for all your middelwares and routes.

Usage

var express = require('express');
var app = express();
var instrumentation = require('instrumentation');
instrumentation(app);

app.use(function prkApp(req, res, next) {
	setTimeout(function() {
		next();
	}, 250);
    
});
app.get('/apptest', function(req, res, next) {
    res.send('apptest');
    next();
});
app.use(function prkApp2(req, res, next) {
    console.log(req.timers);
});
app.listen(3000);

Examples are avaialbe here

Tests

$ npm install
$ npm test

License

The MIT License