mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-20 06:29:53 +01:00
stats: Add http500, memoryUsage, pendingEdits gauges
and turn edits metric into a timer instead of a simple meter
This commit is contained in:
parent
387091c5c9
commit
3ad4b1b837
3 changed files with 14 additions and 2 deletions
|
@ -194,6 +194,7 @@ exports.handleMessage = function(client, message)
|
||||||
if (sessioninfos[client.id].readonly) {
|
if (sessioninfos[client.id].readonly) {
|
||||||
messageLogger.warn("Dropped message, COLLABROOM for readonly pad");
|
messageLogger.warn("Dropped message, COLLABROOM for readonly pad");
|
||||||
} else if (message.data.type == "USER_CHANGES") {
|
} else if (message.data.type == "USER_CHANGES") {
|
||||||
|
stats.counter('pendingEdits').inc()
|
||||||
padChannels.emit(message.padId, {client: client, message: message});// add to pad queue
|
padChannels.emit(message.padId, {client: client, message: message});// add to pad queue
|
||||||
} else if (message.data.type == "USERINFO_UPDATE") {
|
} else if (message.data.type == "USERINFO_UPDATE") {
|
||||||
handleUserInfoUpdate(client, message);
|
handleUserInfoUpdate(client, message);
|
||||||
|
@ -563,6 +564,9 @@ function handleUserChanges(data, cb)
|
||||||
var client = data.client
|
var client = data.client
|
||||||
, message = data.message
|
, message = data.message
|
||||||
|
|
||||||
|
// This one's no longer pending, as we're gonna process it now
|
||||||
|
stats.counter('pendingEdits').dec()
|
||||||
|
|
||||||
// Make sure all required fields are present
|
// Make sure all required fields are present
|
||||||
if(message.data.baseRev == null)
|
if(message.data.baseRev == null)
|
||||||
{
|
{
|
||||||
|
@ -590,8 +594,8 @@ function handleUserChanges(data, cb)
|
||||||
|
|
||||||
var r, apool, pad;
|
var r, apool, pad;
|
||||||
|
|
||||||
// Log edit
|
// Measure time to process edit
|
||||||
stats.meter('edits').mark();
|
var stopWatch = stats.timer('edits').start();
|
||||||
|
|
||||||
async.series([
|
async.series([
|
||||||
//get the pad
|
//get the pad
|
||||||
|
@ -723,6 +727,7 @@ function handleUserChanges(data, cb)
|
||||||
}
|
}
|
||||||
], function(err)
|
], function(err)
|
||||||
{
|
{
|
||||||
|
stopWatch.end()
|
||||||
cb();
|
cb();
|
||||||
if(err) console.warn(err.stack || err)
|
if(err) console.warn(err.stack || err)
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
var os = require("os");
|
var os = require("os");
|
||||||
var db = require('../../db/DB');
|
var db = require('../../db/DB');
|
||||||
|
var stats = require('ep_etherpad-lite/node/stats')
|
||||||
|
|
||||||
|
|
||||||
exports.onShutdown = false;
|
exports.onShutdown = false;
|
||||||
|
@ -40,6 +41,7 @@ exports.expressCreateServer = function (hook_name, args, cb) {
|
||||||
// allowing you to respond however you like
|
// allowing you to respond however you like
|
||||||
res.send(500, { error: 'Sorry, something bad happened!' });
|
res.send(500, { error: 'Sorry, something bad happened!' });
|
||||||
console.error(err.stack? err.stack : err.toString());
|
console.error(err.stack? err.stack : err.toString());
|
||||||
|
stats.meter('http500').mark()
|
||||||
})
|
})
|
||||||
|
|
||||||
//connect graceful shutdown with sigint and uncaughtexception
|
//connect graceful shutdown with sigint and uncaughtexception
|
||||||
|
|
|
@ -23,10 +23,15 @@
|
||||||
|
|
||||||
var log4js = require('log4js')
|
var log4js = require('log4js')
|
||||||
, async = require('async')
|
, async = require('async')
|
||||||
|
, stats = require('./stats')
|
||||||
;
|
;
|
||||||
|
|
||||||
log4js.replaceConsole();
|
log4js.replaceConsole();
|
||||||
|
|
||||||
|
stats.gauge('memoryUsage', function() {
|
||||||
|
return process.memoryUsage().rss
|
||||||
|
})
|
||||||
|
|
||||||
var settings
|
var settings
|
||||||
, db
|
, db
|
||||||
, plugins
|
, plugins
|
||||||
|
|
Loading…
Reference in a new issue