Fix socket count metric leak

This commit is contained in:
Calvin Montgomery 2018-07-09 20:24:53 -07:00
parent 7acae30875
commit 3db751b65f
3 changed files with 3 additions and 60 deletions

View file

@ -218,18 +218,13 @@ class IOServer {
Promise.all(promises).then(() => next());
}
metricsEmittingMiddleware(socket, next) {
emitMetrics(socket);
next();
}
handleConnection(socket) {
// TODO: move out of handleConnection if possible
// see: https://github.com/calzoneman/sync/issues/724
if (!this.checkIPLimit(socket)) {
return;
}
emitMetrics(socket);
LOGGER.info('Accepted socket from %s', socket.context.ipAddress);
counters.add('socket.io:accept', 1);
socket.once('disconnect', () => counters.add('socket.io:disconnect', 1));
@ -257,7 +252,6 @@ class IOServer {
io.use(this.cookieParsingMiddleware.bind(this));
io.use(this.ipSessionCookieMiddleware.bind(this));
io.use(this.authUserMiddleware.bind(this));
io.use(this.metricsEmittingMiddleware.bind(this));
io.on('connection', this.handleConnection.bind(this));
}