From d50b93df2ff5344d95ba111160f2d1b247841b37 Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Tue, 11 Jun 2019 13:53:35 +0100 Subject: [PATCH] add metric for invalid hash and other sharejs errors --- .../app/coffee/ShareJsUpdateManager.coffee | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/services/document-updater/app/coffee/ShareJsUpdateManager.coffee b/services/document-updater/app/coffee/ShareJsUpdateManager.coffee index 66b8367395..e15815373c 100644 --- a/services/document-updater/app/coffee/ShareJsUpdateManager.coffee +++ b/services/document-updater/app/coffee/ShareJsUpdateManager.coffee @@ -48,6 +48,7 @@ module.exports = ShareJsUpdateManager = error = new Errors.DeleteMismatchError("Delete component does not match") return callback(error) else + metrics.inc "sharejs.other-error" return callback(error) logger.log project_id: project_id, doc_id: doc_id, error: error, "applied update" model.getSnapshot doc_key, (error, data) => @@ -55,7 +56,11 @@ module.exports = ShareJsUpdateManager = # only check hash when present and no other updates have been applied if update.hash? and incomingUpdateVersion == version ourHash = ShareJsUpdateManager._computeHash(data.snapshot) - return callback(new Error("Invalid hash")) if ourHash != update.hash + if ourHash != update.hash + metrics.inc "sharejs.hash-fail" + return callback(new Error("Invalid hash")) + else + metrics.inc "sharejs.hash-pass", 0.001 docLines = data.snapshot.split(/\r\n|\n|\r/) callback(null, docLines, data.v, model.db.appliedOps[doc_key] or [])