Add in flags that track how often each callback is called

This commit is contained in:
James Allen 2016-05-26 15:46:45 +01:00
parent 030abc5340
commit 343ec9d708
2 changed files with 6 additions and 2 deletions

View file

@ -23,7 +23,7 @@ module.exports = Router =
attrs.err = error
logger.error attrs, "server side error in #{method}"
# Don't return raw error to prevent leaking server side info
return callback {message: "Something went wrong"}
return callback {message: "Something went wrong in real-time service"}
configure: (app, io, session) ->
app.set("io", io)

View file

@ -149,12 +149,16 @@ module.exports = WebsocketController =
applyOtUpdate: (client, doc_id, update, callback = (error) ->) ->
cbc_0 = 0 # Callback counter
cbc_1 = 0
Utils.getClientAttributes client, ["user_id", "project_id"], (error, {user_id, project_id}) ->
cbc_0++
return callback(error) if error?
return callback(new Error("no project_id found on client")) if !project_id?
# Omit this logging for now since it's likely too noisey
#logger.log {user_id, project_id, doc_id, client_id: client.id, update: update}, "applying update"
AuthorizationManager.assertClientCanEditProject client, (error) ->
cbc_1++
if error?
logger.error {err: error, doc_id, client_id: client.id, version: update.v}, "client is not authorized to make update"
setTimeout () ->
@ -169,7 +173,7 @@ module.exports = WebsocketController =
metrics.set "editor.active-projects", project_id, 0.3
metrics.set "editor.active-users", user_id, 0.3
logger.log {user_id, doc_id, project_id, client_id: client.id, version: update.v}, "sending update to doc updater"
logger.log {user_id, doc_id, project_id, client_id: client.id, version: update.v, cbc_0, cbc_1}, "sending update to doc updater"
DocumentUpdaterManager.queueChange project_id, doc_id, update, (error) ->
if error?