diff --git a/src/node/hooks/express/static.js b/src/node/hooks/express/static.js index 950fe3f78..108f25446 100644 --- a/src/node/hooks/express/static.js +++ b/src/node/hooks/express/static.js @@ -5,8 +5,11 @@ const plugins = require('../../../static/js/pluginfw/plugin_defs'); const CachingMiddleware = require('../../utils/caching_middleware'); const Yajsml = require('etherpad-yajsml'); const _ = require('underscore'); +const stats = require('../../stats'); exports.expressCreateServer = (hookName, args, cb) => { + stats.gauge('minificationDuration', () => minificationDuration); + const preMinification = Date.now(); // Cache both minified and static. const assetCache = new CachingMiddleware(); args.app.all(/\/javascripts\/(.*)/, assetCache.handle); @@ -18,6 +21,10 @@ exports.expressCreateServer = (hookName, args, cb) => { // Setup middleware that will package JavaScript files served by minify for // CommonJS loader on the client-side. // Hostname "invalid.invalid" is a dummy value to allow parsing as a URI. + const minificationDuration = Date.now() - preMinification; + + stats.gauge('YajsmlDuration', () => yajsmlDuration); + const preYajsml = Date.now(); const jsServer = new (Yajsml.Server)({ rootPath: 'javascripts/src/', rootURI: 'http://invalid.invalid/static/js/', @@ -33,6 +40,7 @@ exports.expressCreateServer = (hookName, args, cb) => { jsServer.setAssociator(associator); args.app.use(jsServer.handle.bind(jsServer)); + const yajsmlDuration = Date.now() - preYajsml; // serve plugin definitions // not very static, but served here so that client can do diff --git a/src/node/server.js b/src/node/server.js index 1084ad6ef..47a4b6e3a 100755 --- a/src/node/server.js +++ b/src/node/server.js @@ -62,12 +62,10 @@ exports.start = async () => { // Performance stats gauges // We use gauges because a reload might replace the value - stats.gauge('postNpmLoad', () => preNpmLoad); - stats.gauge('postNpmLoad', () => postNpmLoad); - + stats.gauge('npmLoadDuration', () => postNpmLoad); const preNpmLoad = Date.now() - stats.startTime; await util.promisify(npm.load)(); - const postNpmLoad = Date.now() - stats.startTime; + const npmLoadDuration = Date.now() - stats.startTime; try { stats.gauge('dbInitDuration', () => dbInitDuration);