mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-25 18:25:03 +00:00
debug: log query counts based on operation and table
This commit is contained in:
parent
e71d2f277a
commit
0d2740a3e5
4 changed files with 40 additions and 11 deletions
|
@ -17,7 +17,7 @@ import { RecoverablePluginError } from "./RecoverablePluginError";
|
|||
import { SimpleError } from "./SimpleError";
|
||||
import { ZeppelinGlobalConfig, ZeppelinGuildConfig } from "./types";
|
||||
import { startUptimeCounter } from "./uptime";
|
||||
import { errorMessage, isDiscordAPIError, isDiscordHTTPError, SECONDS, sleep, successMessage } from "./utils";
|
||||
import { errorMessage, isDiscordAPIError, isDiscordHTTPError, MINUTES, SECONDS, sleep, successMessage } from "./utils";
|
||||
import { loadYamlSafely } from "./utils/loadYamlSafely";
|
||||
import { DecayingCounter } from "./utils/DecayingCounter";
|
||||
import { PluginNotLoadedError } from "knub/dist/plugins/PluginNotLoadedError";
|
||||
|
@ -35,6 +35,7 @@ import { setProfiler } from "./profiler";
|
|||
import { enableProfiling } from "./utils/easyProfiler";
|
||||
import { runPhishermanCacheCleanupLoop, runPhishermanReportingLoop } from "./data/loops/phishermanLoops";
|
||||
import { hasPhishermanMasterAPIKey } from "./data/Phisherman";
|
||||
import { consumeQueryStats } from "./data/queryLogger";
|
||||
|
||||
if (!process.env.KEY) {
|
||||
// tslint:disable-next-line:no-console
|
||||
|
@ -388,6 +389,17 @@ connect().then(async () => {
|
|||
lowestGlobalRemaining = Infinity;
|
||||
}, 15000);
|
||||
|
||||
setInterval(() => {
|
||||
const queryStatsMap = consumeQueryStats();
|
||||
const entries = Array.from(queryStatsMap.entries());
|
||||
entries.sort((a, b) => b[1] - a[1]);
|
||||
const topEntriesStr = entries
|
||||
.slice(0, 5)
|
||||
.map(([key, count]) => `${count}x ${key}`)
|
||||
.join("\n");
|
||||
console.log(`Top query entries in the past 5 minutes:\n${topEntriesStr}`);
|
||||
}, 5 * MINUTES);
|
||||
|
||||
bot.initialize();
|
||||
logger.info("Bot Initialized");
|
||||
logger.info("Logging in...");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue