Cookbook - mojodna/node-metricsd GitHub Wiki

Measuring the rate of requests and responses (by statusCode) in Express.js

// assuming you have a metrics instance in scope
function markReqRes(req, res, next) {
    metrics.mark('requests');
    res.once('finish', function() {
        metrics.mark('responses.' + res.statusCode);
    })
    next();
}
// and then in your configure function
app.use(markReqRes);