Konpeki-Discord-Bot/utils/pm2-metrics.js

40 lines
902 B
JavaScript
Raw Normal View History

2022-12-16 03:58:49 -06:00
/*
* Konpeki Discord Bot - Utility Definition File
2022-12-16 03:58:49 -06:00
* pm2-metrics.js - A place to keep all pm2 metrics and error definitions
*/
2022-12-16 02:42:59 -06:00
const io = require('@pm2/io');
const interactionErrors = io.counter({
2023-09-13 07:41:47 -05:00
name: 'Interaction Errors (Since last restart)',
2022-12-16 02:42:59 -06:00
});
const interactionSuccessCounter = io.counter({
2023-09-13 07:41:47 -05:00
name: 'Interaction Successful Runs (Since last restart)',
2022-12-16 02:42:59 -06:00
});
const interactionSuccessMeter = io.meter({
2023-09-13 07:41:47 -05:00
name: 'Successful Interactions per Second',
});
const websocketHeartbeatHist = io.histogram({
2023-09-13 07:41:47 -05:00
name: 'Avg. Websocket Heartbeat (ms) / 5 min.',
measurement: 'mean',
2022-12-16 02:42:59 -06:00
});
const serverCount = io.metric({
2023-09-13 07:41:47 -05:00
name : 'Server Count',
});
2022-12-16 02:42:59 -06:00
const interactionSuccess = function() {
2023-09-13 07:41:47 -05:00
interactionSuccessCounter.inc();
interactionSuccessMeter.mark();
2022-12-16 02:42:59 -06:00
};
module.exports = {
2023-09-13 07:41:47 -05:00
io,
interactionErrors,
interactionSuccess,
websocketHeartbeatHist,
serverCount,
2022-12-16 02:42:59 -06:00
};