express-watcher
v1.0.3
Published
It is a middleware of monitoring Express router, this middleware can be used either globally or on a per-route basis and sends information of response time, used memory and CPU.
Downloads
129
Maintainers
Readme
express-watcher
It is a middleware of monitoring Express router, this middleware can be used either globally or on a per-route basis and sends information of response time, used memory and CPU.
Install
$ npm install --save express-watcher
Usage
var resourceMonitorMiddleware = require('express-watcher').resourceMonitorMiddleware
// example without callback function
app.use(resourceMonitorMiddleware)
Using with Callback
var resourceMonitorMiddlewareCB = require('express-watcher').resourceMonitorMiddlewareCB
// example with callback function
app.use(function(req, res, next){
resourceMonitorMiddlewareCB(req, res, next, function(diffJson){
console.log(' diffJson : ', diffJson)
})
})
// {
// diffRss: 0.0078125,
// diffHeapTotal: 0,
// diffHeapUsed: 0.012725830078125,
// diffExternal: 0,
// diffCpu: 0.000427
// }
Functionality
1- Monitoring each response
Return object as a callback:
{ diffRss: 0.0078125,
diffHeapTotal: 0,
diffHeapUsed: 0.012725830078125,
diffExternal: 0,
diffCpu: 0.000427 }
And auto print:
2- Monitoring all time high information
All time high information is printed when closing (CRT+c) the node process
And auto print:
Reference
- https://www.dynatrace.com/blog/understanding-garbage-collection-and-hunting-memory-leaks-in-node-js/
- https://nodejs.org/api/process.html#process_process