Add try catch around messaging monitoring cron and fix decorators (#7207)
Add try catch around messaging monitoring cron and fix decorators:`@Process` and `@SentryCronMonitor` were inverted.
This commit is contained in:
@ -6,7 +6,7 @@ import { MessageQueueService } from 'src/engine/core-modules/message-queue/servi
|
|||||||
import {
|
import {
|
||||||
MESSAGING_MESSAGE_CHANNEL_SYNC_STATUS_MONITORING_CRON_PATTERN,
|
MESSAGING_MESSAGE_CHANNEL_SYNC_STATUS_MONITORING_CRON_PATTERN,
|
||||||
MessagingMessageChannelSyncStatusMonitoringCronJob,
|
MessagingMessageChannelSyncStatusMonitoringCronJob,
|
||||||
} from 'src/modules/messaging/monitoring/crons/jobs/messaging-message-channel-sync-status-monitoring.cron';
|
} from 'src/modules/messaging/monitoring/crons/jobs/messaging-message-channel-sync-status-monitoring.cron.job';
|
||||||
|
|
||||||
@Command({
|
@Command({
|
||||||
name: 'cron:messaging:monitoring:message-channel-sync-status',
|
name: 'cron:messaging:monitoring:message-channel-sync-status',
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import snakeCase from 'lodash.snakecase';
|
|||||||
import { Repository } from 'typeorm';
|
import { Repository } from 'typeorm';
|
||||||
|
|
||||||
import { SentryCronMonitor } from 'src/engine/core-modules/cron/sentry-cron-monitor.decorator';
|
import { SentryCronMonitor } from 'src/engine/core-modules/cron/sentry-cron-monitor.decorator';
|
||||||
|
import { ExceptionHandlerService } from 'src/engine/core-modules/exception-handler/exception-handler.service';
|
||||||
import { Process } from 'src/engine/core-modules/message-queue/decorators/process.decorator';
|
import { Process } from 'src/engine/core-modules/message-queue/decorators/process.decorator';
|
||||||
import { Processor } from 'src/engine/core-modules/message-queue/decorators/processor.decorator';
|
import { Processor } from 'src/engine/core-modules/message-queue/decorators/processor.decorator';
|
||||||
import { MessageQueue } from 'src/engine/core-modules/message-queue/message-queue.constants';
|
import { MessageQueue } from 'src/engine/core-modules/message-queue/message-queue.constants';
|
||||||
@ -30,13 +31,14 @@ export class MessagingMessageChannelSyncStatusMonitoringCronJob {
|
|||||||
private readonly workspaceRepository: Repository<Workspace>,
|
private readonly workspaceRepository: Repository<Workspace>,
|
||||||
private readonly messagingTelemetryService: MessagingTelemetryService,
|
private readonly messagingTelemetryService: MessagingTelemetryService,
|
||||||
private readonly twentyORMGlobalManager: TwentyORMGlobalManager,
|
private readonly twentyORMGlobalManager: TwentyORMGlobalManager,
|
||||||
|
private readonly exceptionHandlerService: ExceptionHandlerService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
|
@Process(MessagingMessageChannelSyncStatusMonitoringCronJob.name)
|
||||||
@SentryCronMonitor(
|
@SentryCronMonitor(
|
||||||
MessagingMessageChannelSyncStatusMonitoringCronJob.name,
|
MessagingMessageChannelSyncStatusMonitoringCronJob.name,
|
||||||
MESSAGING_MESSAGE_CHANNEL_SYNC_STATUS_MONITORING_CRON_PATTERN,
|
MESSAGING_MESSAGE_CHANNEL_SYNC_STATUS_MONITORING_CRON_PATTERN,
|
||||||
)
|
)
|
||||||
@Process(MessagingMessageChannelSyncStatusMonitoringCronJob.name)
|
|
||||||
async handle(): Promise<void> {
|
async handle(): Promise<void> {
|
||||||
this.logger.log('Starting message channel sync status monitoring...');
|
this.logger.log('Starting message channel sync status monitoring...');
|
||||||
|
|
||||||
@ -54,27 +56,35 @@ export class MessagingMessageChannelSyncStatusMonitoringCronJob {
|
|||||||
});
|
});
|
||||||
|
|
||||||
for (const activeWorkspace of activeWorkspaces) {
|
for (const activeWorkspace of activeWorkspaces) {
|
||||||
const messageChannelRepository =
|
try {
|
||||||
await this.twentyORMGlobalManager.getRepositoryForWorkspace<MessageChannelWorkspaceEntity>(
|
const messageChannelRepository =
|
||||||
activeWorkspace.id,
|
await this.twentyORMGlobalManager.getRepositoryForWorkspace<MessageChannelWorkspaceEntity>(
|
||||||
'messageChannel',
|
activeWorkspace.id,
|
||||||
);
|
'messageChannel',
|
||||||
const messageChannels = await messageChannelRepository.find({
|
);
|
||||||
select: ['id', 'syncStatus', 'connectedAccountId'],
|
const messageChannels = await messageChannelRepository.find({
|
||||||
});
|
select: ['id', 'syncStatus', 'connectedAccountId'],
|
||||||
|
});
|
||||||
|
|
||||||
for (const messageChannel of messageChannels) {
|
for (const messageChannel of messageChannels) {
|
||||||
if (!messageChannel.syncStatus) {
|
if (!messageChannel.syncStatus) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
await this.messagingTelemetryService.track({
|
||||||
|
eventName: `message_channel.monitoring.sync_status.${snakeCase(
|
||||||
|
messageChannel.syncStatus,
|
||||||
|
)}`,
|
||||||
|
workspaceId: activeWorkspace.id,
|
||||||
|
connectedAccountId: messageChannel.connectedAccountId,
|
||||||
|
messageChannelId: messageChannel.id,
|
||||||
|
message: messageChannel.syncStatus,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
await this.messagingTelemetryService.track({
|
} catch (error) {
|
||||||
eventName: `message_channel.monitoring.sync_status.${snakeCase(
|
this.exceptionHandlerService.captureExceptions([error], {
|
||||||
messageChannel.syncStatus,
|
user: {
|
||||||
)}`,
|
workspaceId: activeWorkspace.id,
|
||||||
workspaceId: activeWorkspace.id,
|
},
|
||||||
connectedAccountId: messageChannel.connectedAccountId,
|
|
||||||
messageChannelId: messageChannel.id,
|
|
||||||
message: messageChannel.syncStatus,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -7,7 +7,7 @@ import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity';
|
|||||||
import { DataSourceEntity } from 'src/engine/metadata-modules/data-source/data-source.entity';
|
import { DataSourceEntity } from 'src/engine/metadata-modules/data-source/data-source.entity';
|
||||||
import { MessagingCommonModule } from 'src/modules/messaging/common/messaging-common.module';
|
import { MessagingCommonModule } from 'src/modules/messaging/common/messaging-common.module';
|
||||||
import { MessagingMessageChannelSyncStatusMonitoringCronCommand } from 'src/modules/messaging/monitoring/crons/commands/messaging-message-channel-sync-status-monitoring.cron.command';
|
import { MessagingMessageChannelSyncStatusMonitoringCronCommand } from 'src/modules/messaging/monitoring/crons/commands/messaging-message-channel-sync-status-monitoring.cron.command';
|
||||||
import { MessagingMessageChannelSyncStatusMonitoringCronJob } from 'src/modules/messaging/monitoring/crons/jobs/messaging-message-channel-sync-status-monitoring.cron';
|
import { MessagingMessageChannelSyncStatusMonitoringCronJob } from 'src/modules/messaging/monitoring/crons/jobs/messaging-message-channel-sync-status-monitoring.cron.job';
|
||||||
import { MessagingTelemetryService } from 'src/modules/messaging/monitoring/services/messaging-telemetry.service';
|
import { MessagingTelemetryService } from 'src/modules/messaging/monitoring/services/messaging-telemetry.service';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
|
|||||||
Reference in New Issue
Block a user