From 69f05dc1844322a9135f4f4544e8a1f65b463bf8 Mon Sep 17 00:00:00 2001 From: janderedev Date: Sat, 12 Feb 2022 15:34:55 +0100 Subject: [PATCH] make ping metric not rely on system time --- bot/src/bot/modules/metrics.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bot/src/bot/modules/metrics.ts b/bot/src/bot/modules/metrics.ts index dabfb7d..c31909a 100644 --- a/bot/src/bot/modules/metrics.ts +++ b/bot/src/bot/modules/metrics.ts @@ -2,7 +2,6 @@ import prom from 'prom-client'; import http from 'http'; import logger from '../logger'; import { client } from '../..'; -import { decodeTime } from 'ulid'; const PORT = Number(process.env.BOT_METRICS_PORT); @@ -56,7 +55,7 @@ if (!isNaN(PORT)) { const msg = await channel?.sendMessage('Ping?'); if (!msg) return; - const delay = decodeTime(msg._id) - now; + const delay = Date.now() - now; metrics.msgPing.set(delay); await msg.edit({ content: `Pong! ${delay}ms` }); } catch(e) { console.error(e) }