mirror of
https://github.com/ether/etherpad-lite.git
synced 2026-07-25 02:57:09 +00:00
fix prometheus metric and add total users and active pad count (#7179)
* fix prometheus metric registration * add totalUsers and activePads metric to prometheus
This commit is contained in:
parent
49d431b6b8
commit
06f67b4c01
2 changed files with 42 additions and 18 deletions
|
|
@ -94,14 +94,25 @@ exports.socketio = () => {
|
|||
const sessioninfos:MapArrayType<any> = {};
|
||||
exports.sessioninfos = sessioninfos;
|
||||
|
||||
stats.gauge('totalUsers', () => socketio ? socketio.engine.clientsCount : 0);
|
||||
stats.gauge('activePads', () => {
|
||||
function getTotalActiveUsers() {
|
||||
return socketio ? socketio.engine.clientsCount : 0;
|
||||
}
|
||||
|
||||
exports.getTotalActiveUsers = getTotalActiveUsers;
|
||||
|
||||
function getActivePadCountFromSessionInfos() {
|
||||
const padIds = new Set();
|
||||
for (const {padId} of Object.values(sessioninfos)) {
|
||||
if (!padId) continue;
|
||||
padIds.add(padId);
|
||||
}
|
||||
return padIds.size;
|
||||
}
|
||||
exports.getActivePadCountFromSessionInfos = getActivePadCountFromSessionInfos;
|
||||
|
||||
stats.gauge('totalUsers', () => getTotalActiveUsers());
|
||||
stats.gauge('activePads', () => {
|
||||
return getActivePadCountFromSessionInfos();
|
||||
});
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue