From 1c703f4259f546905f921d563e86849a7dbba452 Mon Sep 17 00:00:00 2001 From: Alec Gibson <12036746+alecgibson@users.noreply.github.com> Date: Mon, 9 Oct 2023 14:10:49 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=88=20Add=20`presence.broadcast`=20`ti?= =?UTF-8?q?ming`=20event?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This change adds a `presence.broadcast` `timing` event, which can be used to monitor Presence broadcast performance. --- lib/agent.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/agent.js b/lib/agent.js index 3c6fa4161..2a44b51c8 100644 --- a/lib/agent.js +++ b/lib/agent.js @@ -776,6 +776,7 @@ Agent.prototype._broadcastPresence = function(presence, callback) { presence: presence, collection: presence.c }; + var start = Date.now(); backend.trigger(backend.MIDDLEWARE_ACTIONS.receivePresence, this, context, function(error) { if (error) return callback(error); backend.transformPresenceToLatestVersion(agent, presence, function(error, presence) { @@ -783,6 +784,7 @@ Agent.prototype._broadcastPresence = function(presence, callback) { var channel = agent._getPresenceChannel(presence.ch); agent.backend.pubsub.publish([channel], presence, function(error) { if (error) return callback(error); + backend.emit('timing', 'presence.broadcast', Date.now() - start); callback(null, presence); }); });