3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-10 12:25:02 +00:00

Add adhoc REST call debug stats

This commit is contained in:
Dragory 2021-09-11 21:14:47 +03:00
parent 3bc0015dbe
commit 07f23d4137
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1
6 changed files with 79 additions and 8 deletions

View file

@ -18,9 +18,10 @@ import { ReloadServerCmd } from "./commands/ReloadServerCmd";
import { RemoveDashboardUserCmd } from "./commands/RemoveDashboardUserCmd";
import { ServersCmd } from "./commands/ServersCmd";
import { BotControlPluginType, ConfigSchema } from "./types";
import { PerformanceCmd } from "./commands/PerformanceCmd";
import { PluginPerformanceCmd } from "./commands/PluginPerformanceCmd";
import { AddServerFromInviteCmd } from "./commands/AddServerFromInviteCmd";
import { ChannelToServerCmd } from "./commands/ChannelToServerCmd";
import { RestPerformanceCmd } from "./commands/RestPerformanceCmd";
const defaultOptions = {
config: {
@ -51,7 +52,8 @@ export const BotControlPlugin = zeppelinGlobalPlugin<BotControlPluginType>()({
ListDashboardUsersCmd,
ListDashboardPermsCmd,
EligibleCmd,
PerformanceCmd,
PluginPerformanceCmd,
RestPerformanceCmd,
AddServerFromInviteCmd,
ChannelToServerCmd,
],

View file

@ -4,8 +4,8 @@ import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
import { createChunkedMessage, formatNumber, resolveInvite, sorter, verboseUserMention } from "../../../utils";
import { botControlCmd } from "../types";
export const PerformanceCmd = botControlCmd({
trigger: ["performance"],
export const PluginPerformanceCmd = botControlCmd({
trigger: ["plugin_performance"],
permission: "can_performance",
signature: {},

View file

@ -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"));
},
});