mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-31 19:02:59 +01:00
PadMessageHandler: Register activePads
metric only once
This commit is contained in:
parent
6011d31b22
commit
4c4415e14a
1 changed files with 8 additions and 13 deletions
|
@ -62,8 +62,15 @@ exports.socketio = () => {
|
||||||
const sessioninfos = {};
|
const sessioninfos = {};
|
||||||
exports.sessioninfos = sessioninfos;
|
exports.sessioninfos = sessioninfos;
|
||||||
|
|
||||||
// Measure total amount of users
|
|
||||||
stats.gauge('totalUsers', () => Object.keys(socketio.sockets.sockets).length);
|
stats.gauge('totalUsers', () => Object.keys(socketio.sockets.sockets).length);
|
||||||
|
stats.gauge('activePads', () => {
|
||||||
|
const padIds = new Set();
|
||||||
|
for (const {padId} of Object.values(sessioninfos)) {
|
||||||
|
if (!padId) continue;
|
||||||
|
padIds.add(padId);
|
||||||
|
}
|
||||||
|
return padIds.size;
|
||||||
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A changeset queue per pad that is processed by handleUserChanges()
|
* A changeset queue per pad that is processed by handleUserChanges()
|
||||||
|
@ -94,18 +101,6 @@ exports.handleConnect = (socket) => {
|
||||||
|
|
||||||
// Initialize sessioninfos for this new session
|
// Initialize sessioninfos for this new session
|
||||||
sessioninfos[socket.id] = {};
|
sessioninfos[socket.id] = {};
|
||||||
|
|
||||||
stats.gauge('activePads', () => {
|
|
||||||
const padIds = [];
|
|
||||||
for (const session of Object.keys(sessioninfos)) {
|
|
||||||
if (sessioninfos[session].padId) {
|
|
||||||
if (padIds.indexOf(sessioninfos[session].padId) === -1) {
|
|
||||||
padIds.push(sessioninfos[session].padId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return padIds.length;
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue