From b8fa1b47a118eb3c587e480823a9a822f484f6b0 Mon Sep 17 00:00:00 2001 From: Rohan Juneja Date: Thu, 10 Aug 2023 14:17:18 -0700 Subject: [PATCH] update environment, sentry error handling --- src/config/index.js | 1 + src/controllers/threading/taskHandler.js | 2 ++ src/middlewares/error.js | 11 ++++++++++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/config/index.js b/src/config/index.js index 0acd33d9..796a76a6 100644 --- a/src/config/index.js +++ b/src/config/index.js @@ -101,6 +101,7 @@ module.exports = class Config { // of transactions for performance monitoring. // We recommend adjusting this value in production tracesSampleRate: process.env.EXPRESS_SAMPLE_RATE ? parseFloat(process.env.EXPRESS_SAMPLE_RATE) : 1.0, + environment: process.env.INSTANCE_ENV }); // RequestHandler creates a separate execution context, so that all diff --git a/src/controllers/threading/taskHandler.js b/src/controllers/threading/taskHandler.js index 64cfdc0f..31043581 100644 --- a/src/controllers/threading/taskHandler.js +++ b/src/controllers/threading/taskHandler.js @@ -19,6 +19,8 @@ Sentry.init({ ...Sentry.autoDiscoverNodePerformanceMonitoringIntegrations(), new ProfilingIntegration() ], + environment: process.env.INSTANCE_ENV, + debug: true, normalizeDepth: 6, maxBreadcrumbs: 500, // Set tracesSampleRate to 1.0 to capture 100% diff --git a/src/middlewares/error.js b/src/middlewares/error.js index 79c0064d..b6222de7 100644 --- a/src/middlewares/error.js +++ b/src/middlewares/error.js @@ -19,6 +19,9 @@ class ErrorHandler { ) { return false; } + if (error.name === "QueryAborted") { + return false; + } return true; } @@ -26,7 +29,10 @@ class ErrorHandler { // first pass through sentry app.use(Sentry.Handlers.errorHandler({ shouldHandleError(error) { - // Capture all 404 and 500 errors + // Do not capture non-server errors + if (error.status && error.status < 500) { + return false; + } if (error instanceof swaggerValidation.InputValidationError || error.name === "InputValidationError") { return false; } @@ -37,6 +43,9 @@ class ErrorHandler { ) { return false; } + if (error.name === "QueryAborted") { + return false; + } return true; } }));