Change metric names to follow prometheus naming guide
This commit is contained in:
parent
92f0a956b9
commit
d0c1e8cbd9
|
|
@ -2,7 +2,7 @@
|
||||||
"author": "Calvin Montgomery",
|
"author": "Calvin Montgomery",
|
||||||
"name": "CyTube",
|
"name": "CyTube",
|
||||||
"description": "Online media synchronizer and chat",
|
"description": "Online media synchronizer and chat",
|
||||||
"version": "3.45.0",
|
"version": "3.46.0",
|
||||||
"repository": {
|
"repository": {
|
||||||
"url": "http://github.com/calzoneman/sync"
|
"url": "http://github.com/calzoneman/sync"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -151,13 +151,13 @@ ChatModule.prototype.restrictNewAccount = function restrictNewAccount(user, data
|
||||||
};
|
};
|
||||||
|
|
||||||
const chatIncomingCount = new Counter({
|
const chatIncomingCount = new Counter({
|
||||||
name: 'cytube_chat_incoming_count',
|
name: 'cytube_chat_incoming_total',
|
||||||
help: 'Number of incoming chatMsg frames'
|
help: 'Number of incoming chatMsg frames'
|
||||||
});
|
});
|
||||||
ChatModule.prototype.handleChatMsg = function (user, data) {
|
ChatModule.prototype.handleChatMsg = function (user, data) {
|
||||||
var self = this;
|
var self = this;
|
||||||
counters.add("chat:incoming");
|
counters.add("chat:incoming");
|
||||||
chatIncomingCount.inc();
|
chatIncomingCount.inc(1, new Date());
|
||||||
|
|
||||||
if (!this.channel || !this.channel.modules.permissions.canChat(user)) {
|
if (!this.channel || !this.channel.modules.permissions.canChat(user)) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -288,7 +288,7 @@ ChatModule.prototype.handlePm = function (user, data) {
|
||||||
};
|
};
|
||||||
|
|
||||||
const chatSentCount = new Counter({
|
const chatSentCount = new Counter({
|
||||||
name: 'cytube_chat_sent_count',
|
name: 'cytube_chat_sent_total',
|
||||||
help: 'Number of broadcast chat messages'
|
help: 'Number of broadcast chat messages'
|
||||||
});
|
});
|
||||||
ChatModule.prototype.processChatMsg = function (user, data) {
|
ChatModule.prototype.processChatMsg = function (user, data) {
|
||||||
|
|
@ -360,7 +360,7 @@ ChatModule.prototype.processChatMsg = function (user, data) {
|
||||||
}
|
}
|
||||||
this.sendMessage(msgobj);
|
this.sendMessage(msgobj);
|
||||||
counters.add("chat:sent");
|
counters.add("chat:sent");
|
||||||
chatSentCount.inc();
|
chatSentCount.inc(1, new Date());
|
||||||
};
|
};
|
||||||
|
|
||||||
ChatModule.prototype.formatMessage = function (username, data) {
|
ChatModule.prototype.formatMessage = function (username, data) {
|
||||||
|
|
|
||||||
|
|
@ -283,7 +283,7 @@ PlaylistModule.prototype.sendPlaylist = function (users) {
|
||||||
};
|
};
|
||||||
|
|
||||||
const changeMediaCounter = new Counter({
|
const changeMediaCounter = new Counter({
|
||||||
name: 'cytube_playlist_played_count',
|
name: 'cytube_playlist_plays_total',
|
||||||
help: 'Counter for number of playlist items played',
|
help: 'Counter for number of playlist items played',
|
||||||
labelNames: ['shortCode']
|
labelNames: ['shortCode']
|
||||||
});
|
});
|
||||||
|
|
@ -301,7 +301,7 @@ PlaylistModule.prototype.sendChangeMedia = function (users) {
|
||||||
var m = this.current.media;
|
var m = this.current.media;
|
||||||
this.channel.logger.log("[playlist] Now playing: " + m.title +
|
this.channel.logger.log("[playlist] Now playing: " + m.title +
|
||||||
" (" + m.type + ":" + m.id + ")");
|
" (" + m.type + ":" + m.id + ")");
|
||||||
changeMediaCounter.labels(m.type).inc();
|
changeMediaCounter.labels(m.type).inc(1, new Date());
|
||||||
} else {
|
} else {
|
||||||
users.forEach(function (u) {
|
users.forEach(function (u) {
|
||||||
u.socket.emit("setCurrent", uid);
|
u.socket.emit("setCurrent", uid);
|
||||||
|
|
|
||||||
|
|
@ -11,11 +11,11 @@ import { Summary, Counter } from 'prom-client';
|
||||||
|
|
||||||
const LOGGER = require('@calzoneman/jsli')('database');
|
const LOGGER = require('@calzoneman/jsli')('database');
|
||||||
const queryLatency = new Summary({
|
const queryLatency = new Summary({
|
||||||
name: 'cytube_db_query_latency',
|
name: 'cytube_db_query_duration_seconds',
|
||||||
help: 'DB query latency (including time spent acquiring connections)'
|
help: 'DB query latency (including time spent acquiring connections)'
|
||||||
});
|
});
|
||||||
const queryCount = new Counter({
|
const queryCount = new Counter({
|
||||||
name: 'cytube_db_query_count',
|
name: 'cytube_db_queries_total',
|
||||||
help: 'DB query count'
|
help: 'DB query count'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -54,7 +54,7 @@ class Database {
|
||||||
return this.knex.transaction(fn).finally(() => {
|
return this.knex.transaction(fn).finally(() => {
|
||||||
end();
|
end();
|
||||||
Metrics.stopTimer(timer);
|
Metrics.stopTimer(timer);
|
||||||
queryCount.inc();
|
queryCount.inc(1, new Date());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ import { lookup as lookupCustomMetadata } from './custom-media';
|
||||||
|
|
||||||
const LOGGER = require('@calzoneman/jsli')('get-info');
|
const LOGGER = require('@calzoneman/jsli')('get-info');
|
||||||
const lookupCounter = new Counter({
|
const lookupCounter = new Counter({
|
||||||
name: 'cytube_media_lookup_count',
|
name: 'cytube_media_lookups_total',
|
||||||
help: 'Count of media lookups',
|
help: 'Count of media lookups',
|
||||||
labelNames: ['shortCode']
|
labelNames: ['shortCode']
|
||||||
});
|
});
|
||||||
|
|
@ -558,7 +558,7 @@ module.exports = {
|
||||||
getMedia: function (id, type, callback) {
|
getMedia: function (id, type, callback) {
|
||||||
if(type in this.Getters) {
|
if(type in this.Getters) {
|
||||||
LOGGER.info("Looking up %s:%s", type, id);
|
LOGGER.info("Looking up %s:%s", type, id);
|
||||||
lookupCounter.labels(type).inc();
|
lookupCounter.labels(type).inc(1, new Date());
|
||||||
this.Getters[type](id, callback);
|
this.Getters[type](id, callback);
|
||||||
} else {
|
} else {
|
||||||
callback("Unknown media type '" + type + "'", null);
|
callback("Unknown media type '" + type + "'", null);
|
||||||
|
|
|
||||||
|
|
@ -196,11 +196,11 @@ class IOServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
const incomingEventCount = new Counter({
|
const incomingEventCount = new Counter({
|
||||||
name: 'cytube_socketio_incoming_events',
|
name: 'cytube_socketio_incoming_events_total',
|
||||||
help: 'Number of received socket.io events from clients'
|
help: 'Number of received socket.io events from clients'
|
||||||
});
|
});
|
||||||
const outgoingPacketCount = new Counter({
|
const outgoingPacketCount = new Counter({
|
||||||
name: 'cytube_socketio_outgoing_packets',
|
name: 'cytube_socketio_outgoing_packets_total',
|
||||||
help: 'Number of outgoing socket.io packets to clients'
|
help: 'Number of outgoing socket.io packets to clients'
|
||||||
});
|
});
|
||||||
function patchSocketMetrics() {
|
function patchSocketMetrics() {
|
||||||
|
|
@ -209,12 +209,12 @@ function patchSocketMetrics() {
|
||||||
|
|
||||||
Socket.prototype.onevent = function patchedOnevent() {
|
Socket.prototype.onevent = function patchedOnevent() {
|
||||||
onevent.apply(this, arguments);
|
onevent.apply(this, arguments);
|
||||||
incomingEventCount.inc();
|
incomingEventCount.inc(1, new Date());
|
||||||
};
|
};
|
||||||
|
|
||||||
Socket.prototype.packet = function patchedPacket() {
|
Socket.prototype.packet = function patchedPacket() {
|
||||||
packet.apply(this, arguments);
|
packet.apply(this, arguments);
|
||||||
outgoingPacketCount.inc();
|
outgoingPacketCount.inc(1, new Date());
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -266,11 +266,11 @@ const promSocketCount = new Gauge({
|
||||||
labelNames: ['transport']
|
labelNames: ['transport']
|
||||||
});
|
});
|
||||||
const promSocketAccept = new Counter({
|
const promSocketAccept = new Counter({
|
||||||
name: 'cytube_sockets_accept_count',
|
name: 'cytube_sockets_accepts_total',
|
||||||
help: 'Counter for number of connections accepted. Excludes rejected connections.'
|
help: 'Counter for number of connections accepted. Excludes rejected connections.'
|
||||||
});
|
});
|
||||||
const promSocketDisconnect = new Counter({
|
const promSocketDisconnect = new Counter({
|
||||||
name: 'cytube_sockets_disconnect_count',
|
name: 'cytube_sockets_disconnects_total',
|
||||||
help: 'Counter for number of connections disconnected.'
|
help: 'Counter for number of connections disconnected.'
|
||||||
});
|
});
|
||||||
function emitMetrics(sock) {
|
function emitMetrics(sock) {
|
||||||
|
|
|
||||||
|
|
@ -32,13 +32,13 @@ function initializeLog(app) {
|
||||||
|
|
||||||
function initPrometheus(app) {
|
function initPrometheus(app) {
|
||||||
const latency = new Summary({
|
const latency = new Summary({
|
||||||
name: 'cytube_http_req_latency',
|
name: 'cytube_http_req_duration_seconds',
|
||||||
help: 'HTTP Request latency from execution of the first middleware '
|
help: 'HTTP Request latency from execution of the first middleware '
|
||||||
+ 'until the "finish" event on the response object.',
|
+ 'until the "finish" event on the response object.',
|
||||||
labelNames: ['method', 'statusCode']
|
labelNames: ['method', 'statusCode']
|
||||||
});
|
});
|
||||||
const requests = new Counter({
|
const requests = new Counter({
|
||||||
name: 'cytube_http_req_count',
|
name: 'cytube_http_req_total',
|
||||||
help: 'HTTP Request count',
|
help: 'HTTP Request count',
|
||||||
labelNames: ['method', 'statusCode']
|
labelNames: ['method', 'statusCode']
|
||||||
});
|
});
|
||||||
|
|
@ -48,8 +48,8 @@ function initPrometheus(app) {
|
||||||
res.on('finish', () => {
|
res.on('finish', () => {
|
||||||
try {
|
try {
|
||||||
const diff = process.hrtime(startTime);
|
const diff = process.hrtime(startTime);
|
||||||
const diffMs = diff[0]*1e3 + diff[1]*1e-6;
|
const diffSec = diff[0] + diff[1]*1e-9;
|
||||||
latency.labels(req.method, res.statusCode).observe(diffMs);
|
latency.labels(req.method, res.statusCode).observe(diffSec);
|
||||||
requests.labels(req.method, res.statusCode).inc(1, new Date());
|
requests.labels(req.method, res.statusCode).inc(1, new Date());
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
LOGGER.error('Failed to record HTTP Prometheus metrics: %s', error.stack);
|
LOGGER.error('Failed to record HTTP Prometheus metrics: %s', error.stack);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue