Skip to content

Commit

Permalink
enhance(backend): improve sentry integration
Browse files Browse the repository at this point in the history
  • Loading branch information
syuilo committed Jun 7, 2024
1 parent 0015786 commit 8592716
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/backend/src/queue/QueueProcessorService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ export class QueueProcessorService implements OnApplicationShutdown {
systemLogger.error(`failed(${err.stack}) id=${job ? job.id : '-'}`, { job, e: renderError(err) });
if (config.sentryForBackend) {
Sentry.captureMessage(`Queue: System: ${job?.name ?? '?'}: ${err.message}`, {
level: 'error',
extra: { job, err },
});
}
Expand Down Expand Up @@ -225,6 +226,7 @@ export class QueueProcessorService implements OnApplicationShutdown {
dbLogger.error(`failed(${err.stack}) id=${job ? job.id : '-'}`, { job, e: renderError(err) });
if (config.sentryForBackend) {
Sentry.captureMessage(`Queue: DB: ${job?.name ?? '?'}: ${err.message}`, {
level: 'error',
extra: { job, err },
});
}
Expand Down Expand Up @@ -264,6 +266,7 @@ export class QueueProcessorService implements OnApplicationShutdown {
deliverLogger.error(`failed(${err.stack}) ${getJobInfo(job)} to=${job ? job.data.to : '-'}`);
if (config.sentryForBackend) {
Sentry.captureMessage(`Queue: Deliver: ${err.message}`, {
level: 'error',
extra: { job, err },
});
}
Expand Down Expand Up @@ -303,6 +306,7 @@ export class QueueProcessorService implements OnApplicationShutdown {
inboxLogger.error(`failed(${err.stack}) ${getJobInfo(job)} activity=${job ? (job.data.activity ? job.data.activity.id : 'none') : '-'}`, { job, e: renderError(err) });
if (config.sentryForBackend) {
Sentry.captureMessage(`Queue: Inbox: ${err.message}`, {
level: 'error',
extra: { job, err },
});
}
Expand Down Expand Up @@ -342,6 +346,7 @@ export class QueueProcessorService implements OnApplicationShutdown {
webhookLogger.error(`failed(${err.stack}) ${getJobInfo(job)} to=${job ? job.data.to : '-'}`);
if (config.sentryForBackend) {
Sentry.captureMessage(`Queue: WebhookDeliver: ${err.message}`, {
level: 'error',
extra: { job, err },
});
}
Expand Down Expand Up @@ -388,6 +393,7 @@ export class QueueProcessorService implements OnApplicationShutdown {
relationshipLogger.error(`failed(${err.stack}) id=${job ? job.id : '-'}`, { job, e: renderError(err) });
if (config.sentryForBackend) {
Sentry.captureMessage(`Queue: Relationship: ${job?.name ?? '?'}: ${err.message}`, {
level: 'error',
extra: { job, err },
});
}
Expand Down Expand Up @@ -428,6 +434,7 @@ export class QueueProcessorService implements OnApplicationShutdown {
objectStorageLogger.error(`failed(${err.stack}) id=${job ? job.id : '-'}`, { job, e: renderError(err) });
if (config.sentryForBackend) {
Sentry.captureMessage(`Queue: ObjectStorage: ${job?.name ?? '?'}: ${err.message}`, {
level: 'error',
extra: { job, err },
});
}
Expand Down
1 change: 1 addition & 0 deletions packages/backend/src/server/api/ApiCallService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ export class ApiCallService implements OnApplicationShutdown {

if (this.config.sentryForBackend) {
Sentry.captureMessage(`Internal error occurred in ${ep.name}: ${err.message}`, {
level: 'error',
user: {
id: userId,
},
Expand Down

0 comments on commit 8592716

Please sign in to comment.