mirror of
https://github.com/TheShadowEevee/Konpeki-Discord-Bot.git
synced 2025-01-11 22:38:50 -06:00
Add PM2 metric tracking for Websocket Heartbeat
This commit is contained in:
parent
519c0520c5
commit
a31a0d8d74
2 changed files with 14 additions and 3 deletions
8
index.js
8
index.js
|
@ -44,6 +44,14 @@ for (const file of commandFiles) {
|
||||||
client.once(Events.ClientReady, c => {
|
client.once(Events.ClientReady, c => {
|
||||||
logger.log(logger.logLevels.INFO, `${logger.colorText('Ready!', logger.textColor.Green)} Logged in as ${logger.colorText(c.user.tag, logger.textColor.Blue)}`);
|
logger.log(logger.logLevels.INFO, `${logger.colorText('Ready!', logger.textColor.Green)} Logged in as ${logger.colorText(c.user.tag, logger.textColor.Blue)}`);
|
||||||
client.user.setPresence({ activities: [{ name: activity }], status: status });
|
client.user.setPresence({ activities: [{ name: activity }], status: status });
|
||||||
|
|
||||||
|
// Track websocket heartbeat with PM2 Histogram
|
||||||
|
let latency = 0;
|
||||||
|
setInterval(function() {
|
||||||
|
latency = c.ws.ping;
|
||||||
|
metrics.websocketHeartbeatHist.update(latency);
|
||||||
|
}, 1000);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Client "on" Events
|
// Client "on" Events
|
||||||
|
|
|
@ -7,17 +7,19 @@ const io = require('@pm2/io');
|
||||||
|
|
||||||
const interactionErrors = io.counter({
|
const interactionErrors = io.counter({
|
||||||
name: 'Interaction Errors (Since last restart)',
|
name: 'Interaction Errors (Since last restart)',
|
||||||
id: 'app/interactions/errors',
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const interactionSuccessCounter = io.counter({
|
const interactionSuccessCounter = io.counter({
|
||||||
name: 'Interaction Successful Runs (Since last restart)',
|
name: 'Interaction Successful Runs (Since last restart)',
|
||||||
id: 'app/interactions/success',
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const interactionSuccessMeter = io.meter({
|
const interactionSuccessMeter = io.meter({
|
||||||
name: 'Successful Interactions per Second',
|
name: 'Successful Interactions per Second',
|
||||||
id: 'app/interactions/success',
|
});
|
||||||
|
|
||||||
|
const websocketHeartbeatHist = io.histogram({
|
||||||
|
name: 'Websocket Heartbeat (ms)',
|
||||||
|
measurement: 'mean',
|
||||||
});
|
});
|
||||||
|
|
||||||
const interactionSuccess = function() {
|
const interactionSuccess = function() {
|
||||||
|
@ -29,4 +31,5 @@ module.exports = {
|
||||||
io,
|
io,
|
||||||
interactionErrors,
|
interactionErrors,
|
||||||
interactionSuccess,
|
interactionSuccess,
|
||||||
|
websocketHeartbeatHist,
|
||||||
};
|
};
|
Loading…
Reference in a new issue