Skip to content

Commit

Permalink
strip out prometheus, bump sentry (again) for anr
Browse files Browse the repository at this point in the history
  • Loading branch information
emallson committed Apr 3, 2024
1 parent f43af12 commit 80c0326
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 150 deletions.
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@
},
"dependencies": {
"@discordjs/rest": "^2.2.0",
"@sentry/node": "^7.83.0",
"@sentry/node": "^7.91.0",
"discord-api-types": "^0.37.65",
"discord.js": "^14.14.1",
"dotenv": "^16.3.1",
"prom-client": "^15.0.0",
"request": "^2.87.0",
"request-promise-native": "^1.0.4",
"uws": "200.0.0"
"request-promise-native": "^1.0.4"
},
"devDependencies": {
"@tsconfig/node20": "^20.1.2",
Expand Down
7 changes: 0 additions & 7 deletions src/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import Discord, { GatewayIntentBits } from "discord.js";

import onReady from "./onReady";
import onMessage, { handleInteraction } from "./onMessage";
import * as metrics from "./metrics";

import "./init";

Expand Down Expand Up @@ -38,15 +37,9 @@ async function buildClient(
client.on("commandError", (e) => console.error("commandError", e));
client.on("guildCreate", async (guild) => {
console.log("Joined server", guild.name, client.guilds.cache.size);
metrics.guildGauge.set(client.guilds.cache.size);

// Set up the counter so that the first response for new servers is counted
// see https://github.com/prometheus/prometheus/issues/3886 or https://github.com/prometheus/prometheus/issues/1673
metrics.messagesSentCounter.labels(guild.name).inc(0);
});
client.on("guildDelete", async (guild) => {
console.log("Left server", guild.name, client.guilds.cache.size);
metrics.guildGauge.set(client.guilds.cache.size);
});
client.on("interactionCreate", (interaction) => {
interaction.isChatInputCommand() && handleInteraction(interaction);
Expand Down
4 changes: 1 addition & 3 deletions src/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import * as Sentry from '@sentry/node';
import fs from 'fs';

import loadDotEnv from './env';
import './metrics';

process.env.NODE_ENV = process.env.NODE_ENV ?? 'development';
const appDirectory = fs.realpathSync(process.cwd());
Expand All @@ -14,7 +13,6 @@ if (process.env.NODE_ENV === 'production') {
Sentry.init({
dsn: 'https://[email protected]/253783',
tracesSampleRate: 1.0,
integrations: [Sentry.anrIntegration({captureStackTrace: true})],
});

Sentry.enableAnrDetection({ captureStackTrace: true }).catch(console.error);
}
37 changes: 0 additions & 37 deletions src/metrics.ts

This file was deleted.

5 changes: 0 additions & 5 deletions src/onMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
putOnCooldown,
checkHistoryPurge,
} from "./memoryHistory";
import * as metrics from "./metrics";
import {
ChatInputCommandInteraction,
Client,
Expand Down Expand Up @@ -228,10 +227,6 @@ export default function onMessage(client: Client, msg: Message) {
}
});

// Metrics
metrics.messagesSentCounter.labels(serverName).inc();
const elapsedMs = process.hrtime(start)[1] / 1000000;
metrics.reportResponseLatencyHistogram.observe(elapsedMs);
} else {
console.warn("No permission to write to this channel.", channelName);
}
Expand Down
11 changes: 0 additions & 11 deletions src/onReady.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,11 @@ import {
SlashCommandBuilder,
SlashCommandStringOption,
} from "discord.js";
import * as metrics from "./metrics";

export default function onReady(client: Client) {
console.log(`Logged in as ${client.user?.tag}!`);
client.user?.setActivity("WoWAnalyzer.com");

const numGuilds = client.guilds.cache.size;
console.log("Currently in", numGuilds, "servers");
metrics.guildGauge.set(numGuilds);

// TODO: Determine if we still need this after the initial setup. I think Prometheus - if they ever saw a server - will then continue to count it properly.
client.guilds.cache.forEach((guild) => {
// Set up the counter so that the first response for is counted
// see https://github.com/prometheus/prometheus/issues/3886 or https://github.com/prometheus/prometheus/issues/1673
metrics.messagesSentCounter.labels(guild.name).inc(0);
});

// FIXME metrics.createServer();
}
120 changes: 37 additions & 83 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -638,11 +638,6 @@
"@jridgewell/resolve-uri" "^3.1.0"
"@jridgewell/sourcemap-codec" "^1.4.14"

"@opentelemetry/api@^1.4.0":
version "1.7.0"
resolved "https://registry.yarnpkg.com/@opentelemetry/api/-/api-1.7.0.tgz#b139c81999c23e3c8d3c0a7234480e945920fc40"
integrity sha512-AdY5wvN0P2vXBi3b29hxZgSFvdhdxPB9+f0B6s//P9Q8nibRWeA3cHm8UmLpio9ABigkVHJ5NMPk+Mz8VCCyrw==

"@sapphire/async-queue@^1.5.0":
version "1.5.0"
resolved "https://registry.npmjs.org/@sapphire/async-queue/-/async-queue-1.5.0.tgz"
Expand All @@ -661,45 +656,44 @@
resolved "https://registry.yarnpkg.com/@sapphire/snowflake/-/snowflake-3.5.1.tgz#254521c188b49e8b2d4cc048b475fb2b38737fec"
integrity sha512-BxcYGzgEsdlG0dKAyOm0ehLGm2CafIrfQTZGWgkfKYbj+pNNsorZ7EotuZukc2MT70E0UbppVbtpBrqpzVzjNA==

"@sentry-internal/tracing@7.83.0":
version "7.83.0"
resolved "https://registry.yarnpkg.com/@sentry-internal/tracing/-/tracing-7.83.0.tgz#8f69d339569b020c495f8350a8ea527c369586e8"
integrity sha512-fY1ZyOiQaaUTuoq5rO+G4/5Ov3n8BnfNK7ck97yAGxy3w+E1CwhVZkXHEvTngNfdYV3ArxvlrtPRb9STFRqXvQ==
"@sentry-internal/tracing@7.109.0":
version "7.109.0"
resolved "https://registry.yarnpkg.com/@sentry-internal/tracing/-/tracing-7.109.0.tgz#3effaa132c41a65378fa98146aea61228d528953"
integrity sha512-PzK/joC5tCuh2R/PRh+7dp+uuZl7pTsBIjPhVZHMTtb9+ls65WkdZJ1/uKXPouyz8NOo9Xok7aEvEo9seongyw==
dependencies:
"@sentry/core" "7.83.0"
"@sentry/types" "7.83.0"
"@sentry/utils" "7.83.0"
"@sentry/core" "7.109.0"
"@sentry/types" "7.109.0"
"@sentry/utils" "7.109.0"

"@sentry/core@7.83.0":
version "7.83.0"
resolved "https://registry.yarnpkg.com/@sentry/core/-/core-7.83.0.tgz#29bdd5aba40a6f25c01c68387b6a9aa13e27f20a"
integrity sha512-fglvpw8aWM6nWXzCjAVXIMTiTEAQ9G9b85IpDd/7L8fuwaFTPQAUSJXupF2PfbpQ3FUYbJt80dxshbERVJG8vQ==
"@sentry/core@7.109.0":
version "7.109.0"
resolved "https://registry.yarnpkg.com/@sentry/core/-/core-7.109.0.tgz#7a02f4af4a676950f6555f552a2a232d4458fcd5"
integrity sha512-xwD4U0IlvvlE/x/g/W1I8b4Cfb16SsCMmiEuBf6XxvAa3OfWBxKoqLifb3GyrbxMC4LbIIZCN/SvLlnGJPgszA==
dependencies:
"@sentry/types" "7.83.0"
"@sentry/utils" "7.83.0"
"@sentry/types" "7.109.0"
"@sentry/utils" "7.109.0"

"@sentry/node@^7.83.0":
version "7.83.0"
resolved "https://registry.yarnpkg.com/@sentry/node/-/node-7.83.0.tgz#199965f4c0cb3cd0d2ae590faa260d2505c38528"
integrity sha512-ibnON+5ovoGOsvcLxcWQu5XAc4rbkvDkzCP74YGnME3/NzRuo3cKam8bUL5Wlm15h68QzxskyNOLuj6BEJ6AfQ==
"@sentry/node@^7.91.0":
version "7.109.0"
resolved "https://registry.yarnpkg.com/@sentry/node/-/node-7.109.0.tgz#dbf152212e42a9b1648ff758ec5bffcb6bb0fa49"
integrity sha512-tqMNAES4X/iBl1eZRCmc29p//0id01FBLEiesNo5nk6ECl6/SaGMFAEwu1gsn90h/Bjgr04slwFOS4cR45V2PQ==
dependencies:
"@sentry-internal/tracing" "7.83.0"
"@sentry/core" "7.83.0"
"@sentry/types" "7.83.0"
"@sentry/utils" "7.83.0"
https-proxy-agent "^5.0.0"
"@sentry-internal/tracing" "7.109.0"
"@sentry/core" "7.109.0"
"@sentry/types" "7.109.0"
"@sentry/utils" "7.109.0"

"@sentry/types@7.83.0":
version "7.83.0"
resolved "https://registry.yarnpkg.com/@sentry/types/-/types-7.83.0.tgz#117e45900603190c547e52bba35e1b3d539d47fb"
integrity sha512-Bd+zJcy8p1VgCfQqUprmUaw0QPWUV+GmCt6zJRHrHTb2pwLahXv6sHJvQ8F8Va6S7Keuy088U+kHzUFGQLMZMQ==
"@sentry/types@7.109.0":
version "7.109.0"
resolved "https://registry.yarnpkg.com/@sentry/types/-/types-7.109.0.tgz#d8778358114ed05be734661cc9e1e261f4494947"
integrity sha512-egCBnDv3YpVFoNzRLdP0soVrxVLCQ+rovREKJ1sw3rA2/MFH9WJ+DZZexsX89yeAFzy1IFsCp7/dEqudusml6g==

"@sentry/utils@7.83.0":
version "7.83.0"
resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-7.83.0.tgz#ec0fc0a468ec35ab9623603f1ba218dd58233eda"
integrity sha512-7SrZtgAn3pHFBqSSvV/VL0CWTBQ7VenJjok4+WGWd6/FhP3fKrEEd9rjVTUb2Pzq9WLJJYzdvxAG8RlggG+H4g==
"@sentry/utils@7.109.0":
version "7.109.0"
resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-7.109.0.tgz#7078e1400197abc1b0c436679bef980639500a86"
integrity sha512-3RjxMOLMBwZ5VSiH84+o/3NY2An4Zldjz0EbfEQNRY9yffRiCPJSQiCJID8EoylCFOh/PAhPimBhqbtWJxX6iw==
dependencies:
"@sentry/types" "7.83.0"
"@sentry/types" "7.109.0"

"@sinclair/typebox@^0.27.8":
version "0.27.8"
Expand Down Expand Up @@ -865,13 +859,6 @@ abbrev@1:
resolved "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz"
integrity sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==

agent-base@6:
version "6.0.2"
resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-6.0.2.tgz#49fff58577cfee3f37176feab4c22e00f86d7f77"
integrity sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==
dependencies:
debug "4"

ajv@^6.12.3:
version "6.12.6"
resolved "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz"
Expand Down Expand Up @@ -1040,11 +1027,6 @@ binary-extensions@^2.0.0:
resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.2.0.tgz#75f502eeaf9ffde42fc98829645be4ea76bd9e2d"
integrity sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==

[email protected]:
version "1.0.1"
resolved "https://registry.npmjs.org/bintrees/-/bintrees-1.0.1.tgz"
integrity sha1-DmVcm5wkNeqraL9AJyJtK1WjRSQ=

brace-expansion@^1.1.7:
version "1.1.11"
resolved "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz"
Expand Down Expand Up @@ -1262,20 +1244,20 @@ dashdash@^1.12.0:
dependencies:
assert-plus "^1.0.0"

debug@4, debug@^4.1.0, debug@^4.1.1:
version "4.3.4"
resolved "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz"
integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==
dependencies:
ms "2.1.2"

debug@^3.2.7:
version "3.2.7"
resolved "https://registry.yarnpkg.com/debug/-/debug-3.2.7.tgz#72580b7e9145fb39b6676f9c5e5fb100b934179a"
integrity sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==
dependencies:
ms "^2.1.1"

debug@^4.1.0, debug@^4.1.1:
version "4.3.4"
resolved "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz"
integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==
dependencies:
ms "2.1.2"

dedent@^1.0.0:
version "1.5.1"
resolved "https://registry.yarnpkg.com/dedent/-/dedent-1.5.1.tgz#4f3fc94c8b711e9bb2800d185cd6ad20f2a90aff"
Expand Down Expand Up @@ -1619,14 +1601,6 @@ http-signature@~1.2.0:
jsprim "^1.2.2"
sshpk "^1.7.0"

https-proxy-agent@^5.0.0:
version "5.0.1"
resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz#c59ef224a04fe8b754f3db0063a25ea30d0005d6"
integrity sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==
dependencies:
agent-base "6"
debug "4"

human-signals@^2.1.0:
version "2.1.0"
resolved "https://registry.npmjs.org/human-signals/-/human-signals-2.1.0.tgz"
Expand Down Expand Up @@ -2491,14 +2465,6 @@ pretty-format@^29.0.0, pretty-format@^29.7.0:
ansi-styles "^5.0.0"
react-is "^18.0.0"

prom-client@^15.0.0:
version "15.0.0"
resolved "https://registry.yarnpkg.com/prom-client/-/prom-client-15.0.0.tgz#067da874a2aa5d2e21bd5cdba9f24a8178bdab6a"
integrity sha512-UocpgIrKyA2TKLVZDSfm8rGkL13C19YrQBAiG3xo3aDFWcHedxRxI3z+cIcucoxpSO0h5lff5iv/SXoxyeopeA==
dependencies:
"@opentelemetry/api" "^1.4.0"
tdigest "^0.1.1"

prompts@^2.0.1:
version "2.4.2"
resolved "https://registry.npmjs.org/prompts/-/prompts-2.4.2.tgz"
Expand Down Expand Up @@ -2788,13 +2754,6 @@ supports-preserve-symlinks-flag@^1.0.0:
resolved "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz"
integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==

tdigest@^0.1.1:
version "0.1.1"
resolved "https://registry.npmjs.org/tdigest/-/tdigest-0.1.1.tgz"
integrity sha1-Ljyyw56kSeVdHmzZEReszKRYgCE=
dependencies:
bintrees "1.0.1"

test-exclude@^6.0.0:
version "6.0.0"
resolved "https://registry.npmjs.org/test-exclude/-/test-exclude-6.0.0.tgz"
Expand Down Expand Up @@ -2919,11 +2878,6 @@ uuid@^3.3.2:
resolved "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz"
integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==

[email protected]:
version "200.0.0"
resolved "https://registry.yarnpkg.com/uws/-/uws-200.0.0.tgz#5f8a72b9b25c0aa98b0c48458f532c29bc0e4135"
integrity sha512-A2j/p+tJBHZ2MtRoMjVqXMzstpyiZkHcV+XzLQ021h63aqHt5P6l0QkR87L0OASvesjMG42Qo97uyEmPB98+3g==

v8-to-istanbul@^9.0.1:
version "9.0.1"
resolved "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-9.0.1.tgz"
Expand Down

0 comments on commit 80c0326

Please sign in to comment.