Add channelCount metrics

This commit is contained in:
calzoneman 2016-05-19 20:09:35 -07:00
parent 58a193b63b
commit fe37cb198e
2 changed files with 26 additions and 2 deletions

View file

@ -8,6 +8,7 @@ import * as Metrics from 'cytube-common/lib/metrics/metrics';
import { JSONFileMetricsReporter } from 'cytube-common/lib/metrics/jsonfilemetricsreporter';
var counters = {};
var server = null;
exports.add = Metrics.incCounter;
@ -26,9 +27,32 @@ function getConnectedSockets() {
}
}
function setChannelCounts(metrics) {
if (server === null) {
server = require('./server').getServer();
}
try {
var publicCount = 0;
var allCount = 0;
server.channels.forEach(function (c) {
allCount++;
if (c.modules.options && c.modules.options.get("show_public")) {
publicCount++;
}
});
metrics.addProperty('channelCount:all', allCount);
metrics.addProperty('channelCount:public', publicCount);
} catch (error) {
Logger.errlog.log(error.stack);
}
}
const reporter = new JSONFileMetricsReporter('counters.log');
Metrics.setReporter(reporter);
Metrics.setReportInterval(60000);
Metrics.addReportHook((metrics) => {
metrics.incCounter('socket.io:count', getConnectedSockets());
metrics.addProperty('socket.io:count', getConnectedSockets());
setChannelCounts(metrics);
});

View file

@ -1121,7 +1121,7 @@ setupCallbacks = function() {
var servers;
if (socketConfig.alt && socketConfig.alt.length > 0 &&
localStorage.useAltServer) {
localStorage.useAltServer === "true") {
servers = socketConfig.alt;
console.log("Using alt servers: " + JSON.stringify(servers));
} else {