make ping metric not rely on system time
This commit is contained in:
parent
75ad95a357
commit
69f05dc184
1 changed files with 1 additions and 2 deletions
|
@ -2,7 +2,6 @@ import prom from 'prom-client';
|
||||||
import http from 'http';
|
import http from 'http';
|
||||||
import logger from '../logger';
|
import logger from '../logger';
|
||||||
import { client } from '../..';
|
import { client } from '../..';
|
||||||
import { decodeTime } from 'ulid';
|
|
||||||
|
|
||||||
const PORT = Number(process.env.BOT_METRICS_PORT);
|
const PORT = Number(process.env.BOT_METRICS_PORT);
|
||||||
|
|
||||||
|
@ -56,7 +55,7 @@ if (!isNaN(PORT)) {
|
||||||
const msg = await channel?.sendMessage('Ping?');
|
const msg = await channel?.sendMessage('Ping?');
|
||||||
if (!msg) return;
|
if (!msg) return;
|
||||||
|
|
||||||
const delay = decodeTime(msg._id) - now;
|
const delay = Date.now() - now;
|
||||||
metrics.msgPing.set(delay);
|
metrics.msgPing.set(delay);
|
||||||
await msg.edit({ content: `Pong! ${delay}ms` });
|
await msg.edit({ content: `Pong! ${delay}ms` });
|
||||||
} catch(e) { console.error(e) }
|
} catch(e) { console.error(e) }
|
||||||
|
|
Loading…
Reference in a new issue