stats: Add http500, memoryUsage, pendingEdits gauges

and turn edits metric into a timer instead of a simple meter
This commit is contained in:
Marcel Klehr 2013-10-27 21:43:32 +01:00
parent 387091c5c9
commit 3ad4b1b837
3 changed files with 14 additions and 2 deletions

View File

@ -194,6 +194,7 @@ exports.handleMessage = function(client, message)
if (sessioninfos[client.id].readonly) {
messageLogger.warn("Dropped message, COLLABROOM for readonly pad");
} else if (message.data.type == "USER_CHANGES") {
stats.counter('pendingEdits').inc()
padChannels.emit(message.padId, {client: client, message: message});// add to pad queue
} else if (message.data.type == "USERINFO_UPDATE") {
handleUserInfoUpdate(client, message);
@ -563,6 +564,9 @@ function handleUserChanges(data, cb)
var client = data.client
, 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
if(message.data.baseRev == null)
{
@ -590,8 +594,8 @@ function handleUserChanges(data, cb)
var r, apool, pad;
// Log edit
stats.meter('edits').mark();
// Measure time to process edit
var stopWatch = stats.timer('edits').start();
async.series([
//get the pad
@ -723,6 +727,7 @@ function handleUserChanges(data, cb)
}
], function(err)
{
stopWatch.end()
cb();
if(err) console.warn(err.stack || err)
});

View File

@ -1,5 +1,6 @@
var os = require("os");
var db = require('../../db/DB');
var stats = require('ep_etherpad-lite/node/stats')
exports.onShutdown = false;
@ -40,6 +41,7 @@ exports.expressCreateServer = function (hook_name, args, cb) {
// allowing you to respond however you like
res.send(500, { error: 'Sorry, something bad happened!' });
console.error(err.stack? err.stack : err.toString());
stats.meter('http500').mark()
})
//connect graceful shutdown with sigint and uncaughtexception

View File

@ -23,10 +23,15 @@
var log4js = require('log4js')
, async = require('async')
, stats = require('./stats')
;
log4js.replaceConsole();
stats.gauge('memoryUsage', function() {
return process.memoryUsage().rss
})
var settings
, db
, plugins