mirror of https://github.com/thaldrin/thaldrin.git
put prometheus stuff everywhere
This commit is contained in:
parent
6f894b31cf
commit
858f4f500f
|
@ -1,12 +1,13 @@
|
||||||
import Logger from "../utils/logger"
|
import Logger from "../utils/logger"
|
||||||
import config from "../../config"
|
import config from "../../config"
|
||||||
import { Guild } from "discord.js"
|
import { Guild } from "discord.js"
|
||||||
|
import Prom from "../utils/init.prometheus";
|
||||||
export = {
|
export = {
|
||||||
name: "guildCreate",
|
name: "guildCreate",
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
run: async (client, guild: Guild) => {
|
run: async (client, guild: Guild) => {
|
||||||
console.log(guild)
|
Prom.guildCount.inc()
|
||||||
|
Prom.totalGuilds.set(client.guilds.cache.size)
|
||||||
Logger.info({
|
Logger.info({
|
||||||
type: "event:guildCreate",
|
type: "event:guildCreate",
|
||||||
message: `New Guild: ${guild.name} [${guild.id}]`
|
message: `New Guild: ${guild.name} [${guild.id}]`
|
||||||
|
|
|
@ -123,6 +123,7 @@ export = {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Prom.commandsExecuted.inc()
|
||||||
let { data: command_usage_data, command_usage_error } = await supabase.from<Usage>('usage').update({ amount: (usage_check_data[0] || { amount: 0 }).amount + 1 }).select().eq("name", cmd.name)
|
let { data: command_usage_data, command_usage_error } = await supabase.from<Usage>('usage').update({ amount: (usage_check_data[0] || { amount: 0 }).amount + 1 }).select().eq("name", cmd.name)
|
||||||
Logger.info({
|
Logger.info({
|
||||||
type: "command:executed",
|
type: "command:executed",
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
import Logger from "../utils/logger"
|
import Logger from "../utils/logger"
|
||||||
import config from "../../config"
|
import config from "../../config"
|
||||||
|
import prom from "../utils/init.prometheus"
|
||||||
export = {
|
export = {
|
||||||
name: "ready",
|
name: "ready",
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
run: async (client: any) => {
|
run: async (client: any) => {
|
||||||
|
prom.totalGuilds.set(client.guilds.cache.size)
|
||||||
Logger.info({
|
Logger.info({
|
||||||
type: "event:ready",
|
type: "event:ready",
|
||||||
message: `${config.variables.name} has started`
|
message: `${config.variables.name} has started`
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
import Logger from "../utils/logger"
|
||||||
|
import { Guild } from "discord.js"
|
||||||
|
import Prom from "../utils/init.prometheus";
|
||||||
|
export = {
|
||||||
|
name: "guildDelete",
|
||||||
|
// @ts-ignore
|
||||||
|
run: async (client, guild: Guild) => {
|
||||||
|
Prom.guildCount.dec()
|
||||||
|
Prom.totalGuilds.set(client.guilds.cache.size)
|
||||||
|
Logger.info({
|
||||||
|
type: "event:guildDelete",
|
||||||
|
message: `Left Guild: ${guild.name} [${guild.id}]`
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,7 +1,4 @@
|
||||||
//! Code taken from NinoDiscord/Nino
|
//! Code taken from NinoDiscord/Nino
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import prom from "prom-client"
|
import prom from "prom-client"
|
||||||
import { createServer, IncomingMessage, ServerResponse } from 'http'
|
import { createServer, IncomingMessage, ServerResponse } from 'http'
|
||||||
import vars from "../../variables"
|
import vars from "../../variables"
|
||||||
|
@ -10,7 +7,8 @@ import Logger from "./logger"
|
||||||
export default class Prometheus {
|
export default class Prometheus {
|
||||||
public commandsExecuted!: prom.Counter<string>
|
public commandsExecuted!: prom.Counter<string>
|
||||||
public messagesSeen!: prom.Counter<string>
|
public messagesSeen!: prom.Counter<string>
|
||||||
public guildCount!: prom.Counter<string>
|
public guildCount!: prom.Gauge<string>
|
||||||
|
public totalGuilds!: prom.Gauge<string>
|
||||||
// public commmandsRan: prom.Counter<string>
|
// public commmandsRan: prom.Counter<string>
|
||||||
#server!: ReturnType<typeof createServer>
|
#server!: ReturnType<typeof createServer>
|
||||||
|
|
||||||
|
@ -28,9 +26,12 @@ export default class Prometheus {
|
||||||
})
|
})
|
||||||
this.guildCount = new prom.Gauge({
|
this.guildCount = new prom.Gauge({
|
||||||
name: "thaldrin_guild_count",
|
name: "thaldrin_guild_count",
|
||||||
help: "Number of Guilds Thaldrin is in"
|
help: "Number of Guilds Thaldrin joined this Lifecycle"
|
||||||
|
})
|
||||||
|
this.totalGuilds = new prom.Gauge({
|
||||||
|
name: "thaldrin_guilds_total",
|
||||||
|
help: "Total Number of Guilds Thaldrin is in"
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
this.#server = createServer(this.onRequest.bind(this));
|
this.#server = createServer(this.onRequest.bind(this));
|
||||||
this.#server.once('listening', () => Logger.info(`Prometheus: Listening at http://localhost:${vars.prometheus.port}`));
|
this.#server.once('listening', () => Logger.info(`Prometheus: Listening at http://localhost:${vars.prometheus.port}`));
|
||||||
|
|
Loading…
Reference in New Issue