diff options
author | Marcel Klehr <mklehr@gmx.net> | 2013-10-27 17:42:55 +0100 |
---|---|---|
committer | Marcel Klehr <mklehr@gmx.net> | 2013-10-27 17:42:55 +0100 |
commit | 940f114a84d8a216e9a3f87f609494b2390d866e (patch) | |
tree | 50e4930289d2f7447a40a765fe9a95e4e3f7047f /src/node/hooks/express | |
parent | b1b801e7c7dfa5c8a9cda44cbf121cd6651b6845 (diff) | |
download | etherpad-lite-940f114a84d8a216e9a3f87f609494b2390d866e.zip |
Record metrics with 'measured'
Diffstat (limited to 'src/node/hooks/express')
-rw-r--r-- | src/node/hooks/express/webaccess.js | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/node/hooks/express/webaccess.js b/src/node/hooks/express/webaccess.js index efced3f7..433d5094 100644 --- a/src/node/hooks/express/webaccess.js +++ b/src/node/hooks/express/webaccess.js @@ -5,6 +5,7 @@ var settings = require('../../utils/Settings'); var randomString = require('ep_etherpad-lite/static/js/pad_utils').randomString; var hooks = require('ep_etherpad-lite/static/js/pluginfw/hooks'); var ueberStore = require('../../db/SessionStore'); +var stats = require('ep_etherpad-lite/node/stats') //checks for basic http auth exports.basicAuth = function (req, res, next) { @@ -91,10 +92,21 @@ exports.basicAuth = function (req, res, next) { exports.secret = null; exports.expressConfigure = function (hook_name, args, cb) { + // Measure response time + args.app.use(function(req, res, next) { + var stopWatch = stats.timer('httpRequests').start(); + var sendFn = res.send + res.send = function() { + stopWatch.end() + sendFn.apply(res, arguments) + } + next() + }) + // If the log level specified in the config file is WARN or ERROR the application server never starts listening to requests as reported in issue #158. // Not installing the log4js connect logger when the log level has a higher severity than INFO since it would not log at that level anyway. if (!(settings.loglevel === "WARN" || settings.loglevel == "ERROR")) - args.app.use(log4js.connectLogger(httpLogger, { level: log4js.levels.DEBUG, format: ':status, :method :url -- :response-timems'})); + args.app.use(log4js.connectLogger(httpLogger, { level: log4js.levels.DEBUG, format: ':status, :method :url'})); /* Do not let express create the session, so that we can retain a * reference to it for socket.io to use. Also, set the key (cookie |