From 9622b341b75a2dd69423aeb92faa9a5b9df82833 Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Mon, 10 May 2021 10:16:50 +0100 Subject: [PATCH] add transport type to metrics --- services/real-time/app/js/Router.js | 4 ++-- services/real-time/app/js/WebsocketController.js | 14 ++++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/services/real-time/app/js/Router.js b/services/real-time/app/js/Router.js index 9b677e39d8..28765ecfa8 100644 --- a/services/real-time/app/js/Router.js +++ b/services/real-time/app/js/Router.js @@ -153,7 +153,7 @@ module.exports = Router = { client.publicId = 'P.' + base64id.generateId() client.emit('connectionAccepted', null, client.publicId) - metrics.inc('socket-io.connection') + metrics.inc('socket-io.connection', 1, { status: client.transport }) metrics.gauge('socket-io.clients', io.sockets.clients().length) logger.log({ session, client_id: client.id }, 'client connected') @@ -211,7 +211,7 @@ module.exports = Router = { }) client.on('disconnect', function () { - metrics.inc('socket-io.disconnect') + metrics.inc('socket-io.disconnect', 1, { status: client.transport }) metrics.gauge('socket-io.clients', io.sockets.clients().length) WebsocketController.leaveProject(io, client, function (err) { diff --git a/services/real-time/app/js/WebsocketController.js b/services/real-time/app/js/WebsocketController.js index f8e32f0788..a54291b0c7 100644 --- a/services/real-time/app/js/WebsocketController.js +++ b/services/real-time/app/js/WebsocketController.js @@ -36,7 +36,7 @@ module.exports = WebsocketController = { { user_id, project_id, client_id: client.id }, 'user joining project' ) - metrics.inc('editor.join-project') + metrics.inc('editor.join-project', 1, { status: client.transport }) WebApiManager.joinProject(project_id, user, function ( error, project, @@ -114,7 +114,7 @@ module.exports = WebsocketController = { return callback() } // client did not join project - metrics.inc('editor.leave-project') + metrics.inc('editor.leave-project', 1, { status: client.transport }) logger.log( { project_id, user_id, client_id: client.id }, 'client leaving project' @@ -167,7 +167,7 @@ module.exports = WebsocketController = { } const joinLeaveEpoch = ++client.joinLeaveEpoch - metrics.inc('editor.join-doc') + metrics.inc('editor.join-doc', 1, { status: client.transport }) const { project_id, user_id, is_restricted_user } = client.ol_context if (!project_id) { return callback(new NotJoinedError()) @@ -319,7 +319,7 @@ module.exports = WebsocketController = { leaveDoc(client, doc_id, callback) { // client may have disconnected, but we have to cleanup internal state. client.joinLeaveEpoch++ - metrics.inc('editor.leave-doc') + metrics.inc('editor.leave-doc', 1, { status: client.transport }) const { project_id, user_id } = client.ol_context logger.log( { user_id, project_id, doc_id, client_id: client.id }, @@ -338,7 +338,9 @@ module.exports = WebsocketController = { return callback() } - metrics.inc('editor.update-client-position', 0.1) + metrics.inc('editor.update-client-position', 0.1, { + status: client.transport + }) const { project_id, first_name, @@ -475,7 +477,7 @@ module.exports = WebsocketController = { } update.meta.source = client.publicId update.meta.user_id = user_id - metrics.inc('editor.doc-update', 0.3) + metrics.inc('editor.doc-update', 0.3, { status: client.transport }) logger.log( {