mirror of
https://github.com/TheShadowEevee/Konpeki-Discord-Bot.git
synced 2025-01-11 14:38:49 -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 => {
|
||||
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 });
|
||||
|
||||
// Track websocket heartbeat with PM2 Histogram
|
||||
let latency = 0;
|
||||
setInterval(function() {
|
||||
latency = c.ws.ping;
|
||||
metrics.websocketHeartbeatHist.update(latency);
|
||||
}, 1000);
|
||||
|
||||
});
|
||||
|
||||
// Client "on" Events
|
||||
|
|
|
@ -7,17 +7,19 @@ const io = require('@pm2/io');
|
|||
|
||||
const interactionErrors = io.counter({
|
||||
name: 'Interaction Errors (Since last restart)',
|
||||
id: 'app/interactions/errors',
|
||||
});
|
||||
|
||||
const interactionSuccessCounter = io.counter({
|
||||
name: 'Interaction Successful Runs (Since last restart)',
|
||||
id: 'app/interactions/success',
|
||||
});
|
||||
|
||||
const interactionSuccessMeter = io.meter({
|
||||
name: 'Successful Interactions per Second',
|
||||
id: 'app/interactions/success',
|
||||
});
|
||||
|
||||
const websocketHeartbeatHist = io.histogram({
|
||||
name: 'Websocket Heartbeat (ms)',
|
||||
measurement: 'mean',
|
||||
});
|
||||
|
||||
const interactionSuccess = function() {
|
||||
|
@ -29,4 +31,5 @@ module.exports = {
|
|||
io,
|
||||
interactionErrors,
|
||||
interactionSuccess,
|
||||
websocketHeartbeatHist,
|
||||
};
|
Loading…
Reference in a new issue