Skip to content

Commit

Permalink
update environment, sentry error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
rjawesome committed Aug 10, 2023
1 parent 1d36e10 commit b8fa1b4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/controllers/threading/taskHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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%
Expand Down
11 changes: 10 additions & 1 deletion src/middlewares/error.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,20 @@ class ErrorHandler {
) {
return false;
}
if (error.name === "QueryAborted") {
return false;
}
return true;
}

setRoutes(app) {
// 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;
}
Expand All @@ -37,6 +43,9 @@ class ErrorHandler {
) {
return false;
}
if (error.name === "QueryAborted") {
return false;
}
return true;
}
}));
Expand Down

0 comments on commit b8fa1b4

Please sign in to comment.