Skip to content

Commit

Permalink
fix(sentry): downgrade to v7, but keep timing changes
Browse files Browse the repository at this point in the history
Sentry v8's node fetch integration seems to heavily slow down start up time (~15-30s extra, mostly with discord.js setup), and since it's fairly helpful to know if a message has been sent right before or anything, I decided to downgrade.
  • Loading branch information
dsevillamartin committed Nov 15, 2024
1 parent 303a08f commit 8747a07
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 1,344 deletions.
17 changes: 16 additions & 1 deletion lib/Util/Log.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,26 @@ class Log {

configureExpressInit(app) {
if (this.sentry) {
Sentry.setupExpressErrorHandler(app);
Sentry.getCurrentHub().getClient().addIntegration(
new Sentry.Integrations.Express({
app,
})
);

app.use(Sentry.Handlers.requestHandler());
app.use(Sentry.Handlers.tracingHandler());

this.info('Sentry | Express initialized');
}
}

configureExpressError(app) {
if (this.sentry) {
app.use(Sentry.Handlers.errorHandler());

this.info('Sentry | Express error handler initialized');
}
}
}

module.exports = new Log();
2 changes: 2 additions & 0 deletions lib/Web/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,8 @@ app.use(function (req, res, next) {
next(new NotFoundError());
});

Log.configureExpressError(app);

app.use((err, req, res, next) => {
const status = err?.status ?? (Number.isInteger(err) ? err : 500);

Expand Down
9 changes: 1 addition & 8 deletions lib/instrument.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
const YappyGitHub = require('./Util/YappyGitHub');

if (process.env.SENTRY) {
console.log(`Sentry | Initializing...`);

const Sentry = require('@sentry/node');
const tracesSampleRate = Number(process.env.SENTRY_SAMPLE_RATE) || 0;

Expand All @@ -11,13 +9,8 @@ if (process.env.SENTRY) {
release: YappyGitHub.git.release,
environment:
process.env.NODE_ENV === 'production' ? 'production' : 'development',
integrations: [
Sentry.httpIntegration({ tracing: true }),
Sentry.expressIntegration(),
],
integrations: [Sentry.httpIntegration({ tracing: true })],
tracesSampleRate,
autoSessionTracking: false,
defaultIntegrations: false,
});

console.log(`Sentry | Initialized (sample rate = ${tracesSampleRate})`);
Expand Down
Loading

0 comments on commit 8747a07

Please sign in to comment.