Add adhoc REST call debug stats
This commit is contained in:
parent
3bc0015dbe
commit
07f23d4137
6 changed files with 79 additions and 8 deletions
|
@ -0,0 +1,24 @@
|
|||
import { TextChannel } from "discord.js";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { createChunkedMessage, formatNumber, resolveInvite, sorter, verboseUserMention } from "../../../utils";
|
||||
import { botControlCmd } from "../types";
|
||||
import { getTopRestCallStats } from "../../../restCallStats";
|
||||
|
||||
const leadingPathRegex = /(?<=\().+\/backend\//g;
|
||||
|
||||
export const RestPerformanceCmd = botControlCmd({
|
||||
trigger: ["rest_performance"],
|
||||
permission: "can_performance",
|
||||
|
||||
signature: {},
|
||||
|
||||
async run({ pluginData, message: msg, args }) {
|
||||
const stats = getTopRestCallStats(5);
|
||||
const formatted = stats.map((callStats) => {
|
||||
const cleanSource = callStats.source.replace(leadingPathRegex, "");
|
||||
return `**${callStats.count} calls**\n${callStats.method.toUpperCase()} ${callStats.path}\n${cleanSource}`;
|
||||
});
|
||||
createChunkedMessage(msg.channel as TextChannel, formatted.join("\n"));
|
||||
},
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue