From 623b6a0a83a59590f8cd350f38dc950e8ec2f425 Mon Sep 17 00:00:00 2001 From: Naomi Carrigan Date: Tue, 13 Aug 2024 08:40:55 -0700 Subject: [PATCH] feat: also track errors --- src/modules/prometheus.ts | 9 +++++++++ src/utils/errorHandler.ts | 1 + 2 files changed, 10 insertions(+) diff --git a/src/modules/prometheus.ts b/src/modules/prometheus.ts index bb38146..b54584a 100644 --- a/src/modules/prometheus.ts +++ b/src/modules/prometheus.ts @@ -8,6 +8,7 @@ export class Prometheus { private entitled: Gauge; private commands: Counter; private users: Gauge; + private errors: Counter; constructor(bot: ExtendedClient) { this.guilds = new Gauge({ @@ -28,6 +29,10 @@ export class Prometheus { help: "The number of users the bot knows." }); this.users.set(bot.users.cache.size); + this.errors = new Counter({ + name: "errors", + help: "The number of errors handled by the process." + }); this.client.collectDefaultMetrics(); } @@ -49,4 +54,8 @@ export class Prometheus { ); this.entitled.set(entitled.size); } + + public errorHandled() { + this.errors.inc(); + } } diff --git a/src/utils/errorHandler.ts b/src/utils/errorHandler.ts index e49b6ba..ae6a50a 100644 --- a/src/utils/errorHandler.ts +++ b/src/utils/errorHandler.ts @@ -37,5 +37,6 @@ export const errorHandler = async ( username: bot.user?.username ?? "Mod bot" }); } + bot.analytics.errorHandled(); return id; };