instrumentation

0.0.4 • Public • Published

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

If you run node.js application in production and wonder why certain request takes too long or why certain request fails. This module could help you to get information regarding running time for each middleware and routes which could help you troubleshoot the problem.

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

Readme

Keywords

none

Package Sidebar

Install

npm i instrumentation

Weekly Downloads

1

Version

0.0.4

License

MIT

Last publish

Collaborators

  • prasannasr6