Merge pull request #73 from overleaf/bg-connected-client-metrics

add connected client count metric
This commit is contained in:
Brian Gough 2019-08-15 09:20:03 +01:00 committed by GitHub
commit 022e47b5c8

View file

@ -56,6 +56,7 @@ module.exports = Router =
client.emit("connectionAccepted") client.emit("connectionAccepted")
metrics.inc('socket-io.connection') metrics.inc('socket-io.connection')
metrics.gauge('socket-io.clients', io.sockets.clients()?.length)
logger.log session: session, client_id: client.id, "client connected" logger.log session: session, client_id: client.id, "client connected"
@ -77,6 +78,7 @@ module.exports = Router =
client.on "disconnect", () -> client.on "disconnect", () ->
metrics.inc('socket-io.disconnect') metrics.inc('socket-io.disconnect')
metrics.gauge('socket-io.clients', io.sockets.clients()?.length - 1)
WebsocketController.leaveProject io, client, (err) -> WebsocketController.leaveProject io, client, (err) ->
if err? if err?
Router._handleError null, err, client, "leaveProject" Router._handleError null, err, client, "leaveProject"