mirror of
https://github.com/twentyhq/twenty.git
synced 2024-12-23 12:02:10 +03:00
Upgrade sentry (#7145)
Upgrave Sentry to v8 and add Sentry Cron monitoring --------- Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
parent
b3ed6cb903
commit
3025ac346c
2
.gitignore
vendored
2
.gitignore
vendored
@ -28,4 +28,4 @@ storybook-static
|
|||||||
.eslintcache
|
.eslintcache
|
||||||
.nyc_output
|
.nyc_output
|
||||||
test-results/
|
test-results/
|
||||||
|
dump.rdb
|
||||||
|
@ -46,10 +46,9 @@
|
|||||||
"@ptc-org/nestjs-query-typeorm": "4.2.1-alpha.2",
|
"@ptc-org/nestjs-query-typeorm": "4.2.1-alpha.2",
|
||||||
"@react-email/components": "0.0.12",
|
"@react-email/components": "0.0.12",
|
||||||
"@react-email/render": "0.0.10",
|
"@react-email/render": "0.0.10",
|
||||||
"@sentry/node": "^7.99.0",
|
"@sentry/node": "^8",
|
||||||
"@sentry/profiling-node": "^1.3.4",
|
"@sentry/profiling-node": "^8",
|
||||||
"@sentry/react": "^7.88.0",
|
"@sentry/react": "^8",
|
||||||
"@sentry/tracing": "^7.99.0",
|
|
||||||
"@sniptt/guards": "^0.2.0",
|
"@sniptt/guards": "^0.2.0",
|
||||||
"@stoplight/elements": "^8.0.5",
|
"@stoplight/elements": "^8.0.5",
|
||||||
"@swc/jest": "^0.2.29",
|
"@swc/jest": "^0.2.29",
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { SentryInitEffect } from '@/error-handler/components/SentryInitiEffect';
|
import { SentryInitEffect } from '@/error-handler/components/SentryInitEffect';
|
||||||
|
|
||||||
export const ExceptionHandlerProvider: React.FC<React.PropsWithChildren> = ({
|
export const ExceptionHandlerProvider: React.FC<React.PropsWithChildren> = ({
|
||||||
children,
|
children,
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { useEffect, useState } from 'react';
|
|
||||||
import * as Sentry from '@sentry/react';
|
import * as Sentry from '@sentry/react';
|
||||||
import { isNonEmptyString } from '@sniptt/guards';
|
import { isNonEmptyString } from '@sniptt/guards';
|
||||||
|
import { useEffect, useState } from 'react';
|
||||||
import { useRecoilValue } from 'recoil';
|
import { useRecoilValue } from 'recoil';
|
||||||
|
|
||||||
import { currentUserState } from '@/auth/states/currentUserState';
|
import { currentUserState } from '@/auth/states/currentUserState';
|
||||||
@ -26,14 +26,10 @@ export const SentryInitEffect = () => {
|
|||||||
release: sentryConfig?.release ?? undefined,
|
release: sentryConfig?.release ?? undefined,
|
||||||
dsn: sentryConfig?.dsn,
|
dsn: sentryConfig?.dsn,
|
||||||
integrations: [
|
integrations: [
|
||||||
new Sentry.BrowserTracing({
|
Sentry.browserTracingIntegration({}),
|
||||||
tracePropagationTargets: [
|
Sentry.replayIntegration(),
|
||||||
'localhost:3001',
|
|
||||||
REACT_APP_SERVER_BASE_URL,
|
|
||||||
],
|
|
||||||
}),
|
|
||||||
new Sentry.Replay(),
|
|
||||||
],
|
],
|
||||||
|
tracePropagationTargets: ['localhost:3001', REACT_APP_SERVER_BASE_URL],
|
||||||
tracesSampleRate: 1.0,
|
tracesSampleRate: 1.0,
|
||||||
replaysSessionSampleRate: 0.1,
|
replaysSessionSampleRate: 0.1,
|
||||||
replaysOnErrorSampleRate: 1.0,
|
replaysOnErrorSampleRate: 1.0,
|
@ -0,0 +1,51 @@
|
|||||||
|
import * as Sentry from '@sentry/node';
|
||||||
|
|
||||||
|
export function SentryCronMonitor(monitorSlug: string, schedule: string) {
|
||||||
|
return function (
|
||||||
|
target: any,
|
||||||
|
propertyKey: string,
|
||||||
|
descriptor: PropertyDescriptor,
|
||||||
|
) {
|
||||||
|
if (!Sentry.isInitialized()) {
|
||||||
|
return descriptor;
|
||||||
|
}
|
||||||
|
|
||||||
|
const originalMethod = descriptor.value;
|
||||||
|
|
||||||
|
descriptor.value = async function (...args: any[]) {
|
||||||
|
try {
|
||||||
|
Sentry.captureCheckIn(
|
||||||
|
{
|
||||||
|
monitorSlug,
|
||||||
|
status: 'in_progress',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
schedule: {
|
||||||
|
type: 'crontab',
|
||||||
|
value: schedule,
|
||||||
|
},
|
||||||
|
checkinMargin: 1,
|
||||||
|
maxRuntime: 1,
|
||||||
|
timezone: 'UTC',
|
||||||
|
},
|
||||||
|
);
|
||||||
|
const result = await originalMethod.apply(this, args);
|
||||||
|
|
||||||
|
Sentry.captureCheckIn({
|
||||||
|
monitorSlug,
|
||||||
|
status: 'ok',
|
||||||
|
});
|
||||||
|
|
||||||
|
return result;
|
||||||
|
} catch (error) {
|
||||||
|
Sentry.captureCheckIn({
|
||||||
|
monitorSlug,
|
||||||
|
status: 'error',
|
||||||
|
});
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return descriptor;
|
||||||
|
};
|
||||||
|
}
|
@ -1,13 +1,14 @@
|
|||||||
import * as Sentry from '@sentry/node';
|
import * as Sentry from '@sentry/node';
|
||||||
import { ProfilingIntegration } from '@sentry/profiling-node';
|
import { nodeProfilingIntegration } from '@sentry/profiling-node';
|
||||||
|
|
||||||
import { ExceptionHandlerUser } from 'src/engine/core-modules/exception-handler/interfaces/exception-handler-user.interface';
|
|
||||||
import { ExceptionHandlerOptions } from 'src/engine/core-modules/exception-handler/interfaces/exception-handler-options.interface';
|
import { ExceptionHandlerOptions } from 'src/engine/core-modules/exception-handler/interfaces/exception-handler-options.interface';
|
||||||
|
import { ExceptionHandlerUser } from 'src/engine/core-modules/exception-handler/interfaces/exception-handler-user.interface';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
ExceptionHandlerDriverInterface,
|
ExceptionHandlerDriverInterface,
|
||||||
ExceptionHandlerSentryDriverFactoryOptions,
|
ExceptionHandlerSentryDriverFactoryOptions,
|
||||||
} from 'src/engine/core-modules/exception-handler/interfaces';
|
} from 'src/engine/core-modules/exception-handler/interfaces';
|
||||||
|
import { WorkspaceCacheKeys } from 'src/engine/workspace-cache-storage/workspace-cache-storage.service';
|
||||||
|
|
||||||
export class ExceptionHandlerSentryDriver
|
export class ExceptionHandlerSentryDriver
|
||||||
implements ExceptionHandlerDriverInterface
|
implements ExceptionHandlerDriverInterface
|
||||||
@ -18,11 +19,17 @@ export class ExceptionHandlerSentryDriver
|
|||||||
release: options.release,
|
release: options.release,
|
||||||
dsn: options.dsn,
|
dsn: options.dsn,
|
||||||
integrations: [
|
integrations: [
|
||||||
new Sentry.Integrations.Http({ tracing: true }),
|
// TODO: Redis integration doesn't seem to work - investigate why
|
||||||
new Sentry.Integrations.Express({ app: options.serverInstance }),
|
Sentry.redisIntegration({
|
||||||
new Sentry.Integrations.GraphQL(),
|
cachePrefixes: Object.values(WorkspaceCacheKeys).map(
|
||||||
new Sentry.Integrations.Postgres(),
|
(key) => `engine:${key}:`,
|
||||||
new ProfilingIntegration(),
|
),
|
||||||
|
}),
|
||||||
|
Sentry.httpIntegration(),
|
||||||
|
Sentry.expressIntegration(),
|
||||||
|
Sentry.graphqlIntegration(),
|
||||||
|
Sentry.postgresIntegration(),
|
||||||
|
nodeProfilingIntegration(),
|
||||||
],
|
],
|
||||||
tracesSampleRate: 0.1,
|
tracesSampleRate: 0.1,
|
||||||
profilesSampleRate: 0.3,
|
profilesSampleRate: 0.3,
|
||||||
|
@ -13,8 +13,6 @@ export class CacheManager<T> {
|
|||||||
const [workspaceId] = cacheKey.split('-');
|
const [workspaceId] = cacheKey.split('-');
|
||||||
|
|
||||||
if (this.cache.has(cacheKey)) {
|
if (this.cache.has(cacheKey)) {
|
||||||
console.log('Cache hit for key:', cacheKey);
|
|
||||||
|
|
||||||
return this.cache.get(cacheKey)!;
|
return this.cache.get(cacheKey)!;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -25,7 +23,6 @@ export class CacheManager<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('Cache miss for key:', cacheKey);
|
|
||||||
const value = await factory();
|
const value = await factory();
|
||||||
|
|
||||||
if (!value) {
|
if (!value) {
|
||||||
|
@ -7,7 +7,7 @@ import { CacheStorageService } from 'src/engine/core-modules/cache-storage/servi
|
|||||||
import { CacheStorageNamespace } from 'src/engine/core-modules/cache-storage/types/cache-storage-namespace.enum';
|
import { CacheStorageNamespace } from 'src/engine/core-modules/cache-storage/types/cache-storage-namespace.enum';
|
||||||
import { ObjectMetadataMap } from 'src/engine/metadata-modules/utils/generate-object-metadata-map.util';
|
import { ObjectMetadataMap } from 'src/engine/metadata-modules/utils/generate-object-metadata-map.util';
|
||||||
|
|
||||||
enum WorkspaceCacheKeys {
|
export enum WorkspaceCacheKeys {
|
||||||
GraphQLTypeDefs = 'graphql:type-defs',
|
GraphQLTypeDefs = 'graphql:type-defs',
|
||||||
GraphQLUsedScalarNames = 'graphql:used-scalar-names',
|
GraphQLUsedScalarNames = 'graphql:used-scalar-names',
|
||||||
GraphQLOperations = 'graphql:operations',
|
GraphQLOperations = 'graphql:operations',
|
||||||
|
@ -3,13 +3,12 @@ import { NestFactory } from '@nestjs/core';
|
|||||||
import { NestExpressApplication } from '@nestjs/platform-express';
|
import { NestExpressApplication } from '@nestjs/platform-express';
|
||||||
|
|
||||||
import * as Sentry from '@sentry/node';
|
import * as Sentry from '@sentry/node';
|
||||||
import '@sentry/tracing';
|
|
||||||
import bytes from 'bytes';
|
import bytes from 'bytes';
|
||||||
import { useContainer } from 'class-validator';
|
import { useContainer } from 'class-validator';
|
||||||
import { graphqlUploadExpress } from 'graphql-upload';
|
import { graphqlUploadExpress } from 'graphql-upload';
|
||||||
|
|
||||||
import { ApplyCorsToExceptions } from 'src/utils/apply-cors-to-exceptions';
|
|
||||||
import { LoggerService } from 'src/engine/core-modules/logger/logger.service';
|
import { LoggerService } from 'src/engine/core-modules/logger/logger.service';
|
||||||
|
import { ApplyCorsToExceptions } from 'src/utils/apply-cors-to-exceptions';
|
||||||
|
|
||||||
import { AppModule } from './app.module';
|
import { AppModule } from './app.module';
|
||||||
|
|
||||||
@ -36,8 +35,7 @@ const bootstrap = async () => {
|
|||||||
app.useLogger(logger);
|
app.useLogger(logger);
|
||||||
|
|
||||||
if (Sentry.isInitialized()) {
|
if (Sentry.isInitialized()) {
|
||||||
app.use(Sentry.Handlers.requestHandler());
|
Sentry.setupExpressErrorHandler(app);
|
||||||
app.use(Sentry.Handlers.tracingHandler());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
app.useGlobalFilters(new ApplyCorsToExceptions());
|
app.useGlobalFilters(new ApplyCorsToExceptions());
|
||||||
|
@ -3,9 +3,10 @@ import { Command, CommandRunner } from 'nest-commander';
|
|||||||
import { InjectMessageQueue } from 'src/engine/core-modules/message-queue/decorators/message-queue.decorator';
|
import { InjectMessageQueue } from 'src/engine/core-modules/message-queue/decorators/message-queue.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';
|
||||||
import { MessageQueueService } from 'src/engine/core-modules/message-queue/services/message-queue.service';
|
import { MessageQueueService } from 'src/engine/core-modules/message-queue/services/message-queue.service';
|
||||||
import { CalendarEventListFetchCronJob } from 'src/modules/calendar/calendar-event-import-manager/crons/jobs/calendar-event-list-fetch.cron.job';
|
import {
|
||||||
|
CALENDAR_EVENTS_IMPORT_CRON_PATTERN,
|
||||||
const CALENDAR_EVENTS_IMPORT_CRON_PATTERN = '*/5 * * * *';
|
CalendarEventListFetchCronJob,
|
||||||
|
} from 'src/modules/calendar/calendar-event-import-manager/crons/jobs/calendar-event-list-fetch.cron.job';
|
||||||
|
|
||||||
@Command({
|
@Command({
|
||||||
name: 'cron:calendar:calendar-event-list-fetch',
|
name: 'cron:calendar:calendar-event-list-fetch',
|
||||||
|
@ -3,9 +3,10 @@ import { Command, CommandRunner } from 'nest-commander';
|
|||||||
import { InjectMessageQueue } from 'src/engine/core-modules/message-queue/decorators/message-queue.decorator';
|
import { InjectMessageQueue } from 'src/engine/core-modules/message-queue/decorators/message-queue.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';
|
||||||
import { MessageQueueService } from 'src/engine/core-modules/message-queue/services/message-queue.service';
|
import { MessageQueueService } from 'src/engine/core-modules/message-queue/services/message-queue.service';
|
||||||
import { CalendarOngoingStaleCronJob } from 'src/modules/calendar/calendar-event-import-manager/crons/jobs/calendar-ongoing-stale.cron.job';
|
import {
|
||||||
|
CALENDAR_ONGOING_STALE_CRON_PATTERN,
|
||||||
const CALENDAR_ONGOING_STALE_CRON_PATTERN = '0 * * * *';
|
CalendarOngoingStaleCronJob,
|
||||||
|
} from 'src/modules/calendar/calendar-event-import-manager/crons/jobs/calendar-ongoing-stale.cron.job';
|
||||||
|
|
||||||
@Command({
|
@Command({
|
||||||
name: 'cron:calendar:ongoing-stale',
|
name: 'cron:calendar:ongoing-stale',
|
||||||
|
@ -2,16 +2,17 @@ import { InjectRepository } from '@nestjs/typeorm';
|
|||||||
|
|
||||||
import { Any, Repository } from 'typeorm';
|
import { Any, Repository } from 'typeorm';
|
||||||
|
|
||||||
import {
|
import { SentryCronMonitor } from 'src/engine/core-modules/cron/sentry-cron-monitor.decorator';
|
||||||
Workspace,
|
|
||||||
WorkspaceActivationStatus,
|
|
||||||
} from 'src/engine/core-modules/workspace/workspace.entity';
|
|
||||||
import { ExceptionHandlerService } from 'src/engine/core-modules/exception-handler/exception-handler.service';
|
import { ExceptionHandlerService } from 'src/engine/core-modules/exception-handler/exception-handler.service';
|
||||||
import { InjectMessageQueue } from 'src/engine/core-modules/message-queue/decorators/message-queue.decorator';
|
import { InjectMessageQueue } from 'src/engine/core-modules/message-queue/decorators/message-queue.decorator';
|
||||||
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';
|
||||||
import { MessageQueueService } from 'src/engine/core-modules/message-queue/services/message-queue.service';
|
import { MessageQueueService } from 'src/engine/core-modules/message-queue/services/message-queue.service';
|
||||||
|
import {
|
||||||
|
Workspace,
|
||||||
|
WorkspaceActivationStatus,
|
||||||
|
} from 'src/engine/core-modules/workspace/workspace.entity';
|
||||||
import { TwentyORMGlobalManager } from 'src/engine/twenty-orm/twenty-orm-global.manager';
|
import { TwentyORMGlobalManager } from 'src/engine/twenty-orm/twenty-orm-global.manager';
|
||||||
import {
|
import {
|
||||||
CalendarEventListFetchJob,
|
CalendarEventListFetchJob,
|
||||||
@ -19,6 +20,8 @@ import {
|
|||||||
} from 'src/modules/calendar/calendar-event-import-manager/jobs/calendar-event-list-fetch.job';
|
} from 'src/modules/calendar/calendar-event-import-manager/jobs/calendar-event-list-fetch.job';
|
||||||
import { CalendarChannelSyncStage } from 'src/modules/calendar/common/standard-objects/calendar-channel.workspace-entity';
|
import { CalendarChannelSyncStage } from 'src/modules/calendar/common/standard-objects/calendar-channel.workspace-entity';
|
||||||
|
|
||||||
|
export const CALENDAR_EVENTS_IMPORT_CRON_PATTERN = '*/5 * * * *';
|
||||||
|
|
||||||
@Processor({
|
@Processor({
|
||||||
queueName: MessageQueue.cronQueue,
|
queueName: MessageQueue.cronQueue,
|
||||||
})
|
})
|
||||||
@ -33,6 +36,10 @@ export class CalendarEventListFetchCronJob {
|
|||||||
) {}
|
) {}
|
||||||
|
|
||||||
@Process(CalendarEventListFetchCronJob.name)
|
@Process(CalendarEventListFetchCronJob.name)
|
||||||
|
@SentryCronMonitor(
|
||||||
|
CalendarEventListFetchCronJob.name,
|
||||||
|
CALENDAR_EVENTS_IMPORT_CRON_PATTERN,
|
||||||
|
)
|
||||||
async handle(): Promise<void> {
|
async handle(): Promise<void> {
|
||||||
console.time('CalendarEventListFetchCronJob time');
|
console.time('CalendarEventListFetchCronJob time');
|
||||||
|
|
||||||
|
@ -2,21 +2,24 @@ import { InjectRepository } from '@nestjs/typeorm';
|
|||||||
|
|
||||||
import { Repository } from 'typeorm';
|
import { Repository } from 'typeorm';
|
||||||
|
|
||||||
import {
|
import { SentryCronMonitor } from 'src/engine/core-modules/cron/sentry-cron-monitor.decorator';
|
||||||
Workspace,
|
|
||||||
WorkspaceActivationStatus,
|
|
||||||
} from 'src/engine/core-modules/workspace/workspace.entity';
|
|
||||||
import { ExceptionHandlerService } from 'src/engine/core-modules/exception-handler/exception-handler.service';
|
import { ExceptionHandlerService } from 'src/engine/core-modules/exception-handler/exception-handler.service';
|
||||||
import { InjectMessageQueue } from 'src/engine/core-modules/message-queue/decorators/message-queue.decorator';
|
import { InjectMessageQueue } from 'src/engine/core-modules/message-queue/decorators/message-queue.decorator';
|
||||||
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';
|
||||||
import { MessageQueueService } from 'src/engine/core-modules/message-queue/services/message-queue.service';
|
import { MessageQueueService } from 'src/engine/core-modules/message-queue/services/message-queue.service';
|
||||||
|
import {
|
||||||
|
Workspace,
|
||||||
|
WorkspaceActivationStatus,
|
||||||
|
} from 'src/engine/core-modules/workspace/workspace.entity';
|
||||||
import {
|
import {
|
||||||
CalendarOngoingStaleJob,
|
CalendarOngoingStaleJob,
|
||||||
CalendarOngoingStaleJobData,
|
CalendarOngoingStaleJobData,
|
||||||
} from 'src/modules/calendar/calendar-event-import-manager/jobs/calendar-ongoing-stale.job';
|
} from 'src/modules/calendar/calendar-event-import-manager/jobs/calendar-ongoing-stale.job';
|
||||||
|
|
||||||
|
export const CALENDAR_ONGOING_STALE_CRON_PATTERN = '0 * * * *';
|
||||||
|
|
||||||
@Processor(MessageQueue.cronQueue)
|
@Processor(MessageQueue.cronQueue)
|
||||||
export class CalendarOngoingStaleCronJob {
|
export class CalendarOngoingStaleCronJob {
|
||||||
constructor(
|
constructor(
|
||||||
@ -28,6 +31,10 @@ export class CalendarOngoingStaleCronJob {
|
|||||||
) {}
|
) {}
|
||||||
|
|
||||||
@Process(CalendarOngoingStaleCronJob.name)
|
@Process(CalendarOngoingStaleCronJob.name)
|
||||||
|
@SentryCronMonitor(
|
||||||
|
CalendarOngoingStaleCronJob.name,
|
||||||
|
CALENDAR_ONGOING_STALE_CRON_PATTERN,
|
||||||
|
)
|
||||||
async handle(): Promise<void> {
|
async handle(): Promise<void> {
|
||||||
const activeWorkspaces = await this.workspaceRepository.find({
|
const activeWorkspaces = await this.workspaceRepository.find({
|
||||||
where: {
|
where: {
|
||||||
|
@ -3,9 +3,10 @@ import { Command, CommandRunner } from 'nest-commander';
|
|||||||
import { InjectMessageQueue } from 'src/engine/core-modules/message-queue/decorators/message-queue.decorator';
|
import { InjectMessageQueue } from 'src/engine/core-modules/message-queue/decorators/message-queue.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';
|
||||||
import { MessageQueueService } from 'src/engine/core-modules/message-queue/services/message-queue.service';
|
import { MessageQueueService } from 'src/engine/core-modules/message-queue/services/message-queue.service';
|
||||||
import { MessagingMessageListFetchCronJob } from 'src/modules/messaging/message-import-manager/crons/jobs/messaging-message-list-fetch.cron.job';
|
import {
|
||||||
|
MESSAGING_MESSAGE_LIST_FETCH_CRON_PATTERN,
|
||||||
const MESSAGING_MESSAGE_LIST_FETCH_CRON_PATTERN = '*/5 * * * *';
|
MessagingMessageListFetchCronJob,
|
||||||
|
} from 'src/modules/messaging/message-import-manager/crons/jobs/messaging-message-list-fetch.cron.job';
|
||||||
|
|
||||||
@Command({
|
@Command({
|
||||||
name: 'cron:messaging:message-list-fetch',
|
name: 'cron:messaging:message-list-fetch',
|
||||||
|
@ -3,9 +3,10 @@ import { Command, CommandRunner } from 'nest-commander';
|
|||||||
import { InjectMessageQueue } from 'src/engine/core-modules/message-queue/decorators/message-queue.decorator';
|
import { InjectMessageQueue } from 'src/engine/core-modules/message-queue/decorators/message-queue.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';
|
||||||
import { MessageQueueService } from 'src/engine/core-modules/message-queue/services/message-queue.service';
|
import { MessageQueueService } from 'src/engine/core-modules/message-queue/services/message-queue.service';
|
||||||
import { MessagingMessagesImportCronJob } from 'src/modules/messaging/message-import-manager/crons/jobs/messaging-messages-import.cron.job';
|
import {
|
||||||
|
MESSAGING_MESSAGES_IMPORT_CRON_PATTERN,
|
||||||
const MESSAGING_MESSAGES_IMPORT_CRON_PATTERN = '*/1 * * * *';
|
MessagingMessagesImportCronJob,
|
||||||
|
} from 'src/modules/messaging/message-import-manager/crons/jobs/messaging-messages-import.cron.job';
|
||||||
|
|
||||||
@Command({
|
@Command({
|
||||||
name: 'cron:messaging:messages-import',
|
name: 'cron:messaging:messages-import',
|
||||||
|
@ -3,9 +3,10 @@ import { Command, CommandRunner } from 'nest-commander';
|
|||||||
import { InjectMessageQueue } from 'src/engine/core-modules/message-queue/decorators/message-queue.decorator';
|
import { InjectMessageQueue } from 'src/engine/core-modules/message-queue/decorators/message-queue.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';
|
||||||
import { MessageQueueService } from 'src/engine/core-modules/message-queue/services/message-queue.service';
|
import { MessageQueueService } from 'src/engine/core-modules/message-queue/services/message-queue.service';
|
||||||
import { MessagingOngoingStaleCronJob } from 'src/modules/messaging/message-import-manager/crons/jobs/messaging-ongoing-stale.cron.job';
|
import {
|
||||||
|
MESSAGING_ONGOING_STALE_CRON_PATTERN,
|
||||||
const MESSAGING_ONGOING_STALE_CRON_PATTERN = '0 * * * *';
|
MessagingOngoingStaleCronJob,
|
||||||
|
} from 'src/modules/messaging/message-import-manager/crons/jobs/messaging-ongoing-stale.cron.job';
|
||||||
|
|
||||||
@Command({
|
@Command({
|
||||||
name: 'cron:messaging:ongoing-stale',
|
name: 'cron:messaging:ongoing-stale',
|
||||||
|
@ -2,16 +2,17 @@ import { InjectRepository } from '@nestjs/typeorm';
|
|||||||
|
|
||||||
import { In, Repository } from 'typeorm';
|
import { In, Repository } from 'typeorm';
|
||||||
|
|
||||||
import {
|
import { SentryCronMonitor } from 'src/engine/core-modules/cron/sentry-cron-monitor.decorator';
|
||||||
Workspace,
|
|
||||||
WorkspaceActivationStatus,
|
|
||||||
} from 'src/engine/core-modules/workspace/workspace.entity';
|
|
||||||
import { ExceptionHandlerService } from 'src/engine/core-modules/exception-handler/exception-handler.service';
|
import { ExceptionHandlerService } from 'src/engine/core-modules/exception-handler/exception-handler.service';
|
||||||
import { InjectMessageQueue } from 'src/engine/core-modules/message-queue/decorators/message-queue.decorator';
|
import { InjectMessageQueue } from 'src/engine/core-modules/message-queue/decorators/message-queue.decorator';
|
||||||
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';
|
||||||
import { MessageQueueService } from 'src/engine/core-modules/message-queue/services/message-queue.service';
|
import { MessageQueueService } from 'src/engine/core-modules/message-queue/services/message-queue.service';
|
||||||
|
import {
|
||||||
|
Workspace,
|
||||||
|
WorkspaceActivationStatus,
|
||||||
|
} from 'src/engine/core-modules/workspace/workspace.entity';
|
||||||
import { TwentyORMGlobalManager } from 'src/engine/twenty-orm/twenty-orm-global.manager';
|
import { TwentyORMGlobalManager } from 'src/engine/twenty-orm/twenty-orm-global.manager';
|
||||||
import {
|
import {
|
||||||
MessageChannelSyncStage,
|
MessageChannelSyncStage,
|
||||||
@ -22,6 +23,8 @@ import {
|
|||||||
MessagingMessageListFetchJobData,
|
MessagingMessageListFetchJobData,
|
||||||
} from 'src/modules/messaging/message-import-manager/jobs/messaging-message-list-fetch.job';
|
} from 'src/modules/messaging/message-import-manager/jobs/messaging-message-list-fetch.job';
|
||||||
|
|
||||||
|
export const MESSAGING_MESSAGE_LIST_FETCH_CRON_PATTERN = '*/5 * * * *';
|
||||||
|
|
||||||
@Processor(MessageQueue.cronQueue)
|
@Processor(MessageQueue.cronQueue)
|
||||||
export class MessagingMessageListFetchCronJob {
|
export class MessagingMessageListFetchCronJob {
|
||||||
constructor(
|
constructor(
|
||||||
@ -34,6 +37,10 @@ export class MessagingMessageListFetchCronJob {
|
|||||||
) {}
|
) {}
|
||||||
|
|
||||||
@Process(MessagingMessageListFetchCronJob.name)
|
@Process(MessagingMessageListFetchCronJob.name)
|
||||||
|
@SentryCronMonitor(
|
||||||
|
MessagingMessageListFetchCronJob.name,
|
||||||
|
MESSAGING_MESSAGE_LIST_FETCH_CRON_PATTERN,
|
||||||
|
)
|
||||||
async handle(): Promise<void> {
|
async handle(): Promise<void> {
|
||||||
console.time('MessagingMessageListFetchCronJob time');
|
console.time('MessagingMessageListFetchCronJob time');
|
||||||
|
|
||||||
|
@ -2,16 +2,17 @@ import { InjectRepository } from '@nestjs/typeorm';
|
|||||||
|
|
||||||
import { Repository } from 'typeorm';
|
import { Repository } from 'typeorm';
|
||||||
|
|
||||||
import {
|
import { SentryCronMonitor } from 'src/engine/core-modules/cron/sentry-cron-monitor.decorator';
|
||||||
Workspace,
|
|
||||||
WorkspaceActivationStatus,
|
|
||||||
} from 'src/engine/core-modules/workspace/workspace.entity';
|
|
||||||
import { ExceptionHandlerService } from 'src/engine/core-modules/exception-handler/exception-handler.service';
|
import { ExceptionHandlerService } from 'src/engine/core-modules/exception-handler/exception-handler.service';
|
||||||
import { InjectMessageQueue } from 'src/engine/core-modules/message-queue/decorators/message-queue.decorator';
|
import { InjectMessageQueue } from 'src/engine/core-modules/message-queue/decorators/message-queue.decorator';
|
||||||
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';
|
||||||
import { MessageQueueService } from 'src/engine/core-modules/message-queue/services/message-queue.service';
|
import { MessageQueueService } from 'src/engine/core-modules/message-queue/services/message-queue.service';
|
||||||
|
import {
|
||||||
|
Workspace,
|
||||||
|
WorkspaceActivationStatus,
|
||||||
|
} from 'src/engine/core-modules/workspace/workspace.entity';
|
||||||
import { TwentyORMGlobalManager } from 'src/engine/twenty-orm/twenty-orm-global.manager';
|
import { TwentyORMGlobalManager } from 'src/engine/twenty-orm/twenty-orm-global.manager';
|
||||||
import {
|
import {
|
||||||
MessageChannelSyncStage,
|
MessageChannelSyncStage,
|
||||||
@ -22,6 +23,8 @@ import {
|
|||||||
MessagingMessagesImportJobData,
|
MessagingMessagesImportJobData,
|
||||||
} from 'src/modules/messaging/message-import-manager/jobs/messaging-messages-import.job';
|
} from 'src/modules/messaging/message-import-manager/jobs/messaging-messages-import.job';
|
||||||
|
|
||||||
|
export const MESSAGING_MESSAGES_IMPORT_CRON_PATTERN = '*/1 * * * *';
|
||||||
|
|
||||||
@Processor(MessageQueue.cronQueue)
|
@Processor(MessageQueue.cronQueue)
|
||||||
export class MessagingMessagesImportCronJob {
|
export class MessagingMessagesImportCronJob {
|
||||||
constructor(
|
constructor(
|
||||||
@ -34,6 +37,10 @@ export class MessagingMessagesImportCronJob {
|
|||||||
) {}
|
) {}
|
||||||
|
|
||||||
@Process(MessagingMessagesImportCronJob.name)
|
@Process(MessagingMessagesImportCronJob.name)
|
||||||
|
@SentryCronMonitor(
|
||||||
|
MessagingMessagesImportCronJob.name,
|
||||||
|
MESSAGING_MESSAGES_IMPORT_CRON_PATTERN,
|
||||||
|
)
|
||||||
async handle(): Promise<void> {
|
async handle(): Promise<void> {
|
||||||
console.time('MessagingMessagesImportCronJob time');
|
console.time('MessagingMessagesImportCronJob time');
|
||||||
|
|
||||||
|
@ -2,21 +2,24 @@ import { InjectRepository } from '@nestjs/typeorm';
|
|||||||
|
|
||||||
import { Repository } from 'typeorm';
|
import { Repository } from 'typeorm';
|
||||||
|
|
||||||
import {
|
import { SentryCronMonitor } from 'src/engine/core-modules/cron/sentry-cron-monitor.decorator';
|
||||||
Workspace,
|
|
||||||
WorkspaceActivationStatus,
|
|
||||||
} from 'src/engine/core-modules/workspace/workspace.entity';
|
|
||||||
import { ExceptionHandlerService } from 'src/engine/core-modules/exception-handler/exception-handler.service';
|
import { ExceptionHandlerService } from 'src/engine/core-modules/exception-handler/exception-handler.service';
|
||||||
import { InjectMessageQueue } from 'src/engine/core-modules/message-queue/decorators/message-queue.decorator';
|
import { InjectMessageQueue } from 'src/engine/core-modules/message-queue/decorators/message-queue.decorator';
|
||||||
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';
|
||||||
import { MessageQueueService } from 'src/engine/core-modules/message-queue/services/message-queue.service';
|
import { MessageQueueService } from 'src/engine/core-modules/message-queue/services/message-queue.service';
|
||||||
|
import {
|
||||||
|
Workspace,
|
||||||
|
WorkspaceActivationStatus,
|
||||||
|
} from 'src/engine/core-modules/workspace/workspace.entity';
|
||||||
import {
|
import {
|
||||||
MessagingOngoingStaleJob,
|
MessagingOngoingStaleJob,
|
||||||
MessagingOngoingStaleJobData,
|
MessagingOngoingStaleJobData,
|
||||||
} from 'src/modules/messaging/message-import-manager/jobs/messaging-ongoing-stale.job';
|
} from 'src/modules/messaging/message-import-manager/jobs/messaging-ongoing-stale.job';
|
||||||
|
|
||||||
|
export const MESSAGING_ONGOING_STALE_CRON_PATTERN = '0 * * * *';
|
||||||
|
|
||||||
@Processor(MessageQueue.cronQueue)
|
@Processor(MessageQueue.cronQueue)
|
||||||
export class MessagingOngoingStaleCronJob {
|
export class MessagingOngoingStaleCronJob {
|
||||||
constructor(
|
constructor(
|
||||||
@ -28,6 +31,10 @@ export class MessagingOngoingStaleCronJob {
|
|||||||
) {}
|
) {}
|
||||||
|
|
||||||
@Process(MessagingOngoingStaleCronJob.name)
|
@Process(MessagingOngoingStaleCronJob.name)
|
||||||
|
@SentryCronMonitor(
|
||||||
|
MessagingOngoingStaleCronJob.name,
|
||||||
|
MESSAGING_ONGOING_STALE_CRON_PATTERN,
|
||||||
|
)
|
||||||
async handle(): Promise<void> {
|
async handle(): Promise<void> {
|
||||||
const activeWorkspaces = await this.workspaceRepository.find({
|
const activeWorkspaces = await this.workspaceRepository.find({
|
||||||
where: {
|
where: {
|
||||||
|
@ -3,10 +3,10 @@ import { Command, CommandRunner } from 'nest-commander';
|
|||||||
import { InjectMessageQueue } from 'src/engine/core-modules/message-queue/decorators/message-queue.decorator';
|
import { InjectMessageQueue } from 'src/engine/core-modules/message-queue/decorators/message-queue.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';
|
||||||
import { MessageQueueService } from 'src/engine/core-modules/message-queue/services/message-queue.service';
|
import { MessageQueueService } from 'src/engine/core-modules/message-queue/services/message-queue.service';
|
||||||
import { MessagingMessageChannelSyncStatusMonitoringCronJob } from 'src/modules/messaging/monitoring/crons/jobs/messaging-message-channel-sync-status-monitoring.cron';
|
import {
|
||||||
|
MESSAGING_MESSAGE_CHANNEL_SYNC_STATUS_MONITORING_CRON_PATTERN,
|
||||||
const MESSAGING_MESSAGE_CHANNEL_SYNC_STATUS_MONITORING_CRON_PATTERN =
|
MessagingMessageChannelSyncStatusMonitoringCronJob,
|
||||||
'2/10 * * * *'; //Every 10 minutes, starting at 2 minutes past the hour
|
} from 'src/modules/messaging/monitoring/crons/jobs/messaging-message-channel-sync-status-monitoring.cron';
|
||||||
|
|
||||||
@Command({
|
@Command({
|
||||||
name: 'cron:messaging:monitoring:message-channel-sync-status',
|
name: 'cron:messaging:monitoring:message-channel-sync-status',
|
||||||
|
@ -4,17 +4,21 @@ import { InjectRepository } from '@nestjs/typeorm';
|
|||||||
import snakeCase from 'lodash.snakecase';
|
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 { Process } from 'src/engine/core-modules/message-queue/decorators/process.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 {
|
import {
|
||||||
Workspace,
|
Workspace,
|
||||||
WorkspaceActivationStatus,
|
WorkspaceActivationStatus,
|
||||||
} from 'src/engine/core-modules/workspace/workspace.entity';
|
} from 'src/engine/core-modules/workspace/workspace.entity';
|
||||||
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 { MessageQueue } from 'src/engine/core-modules/message-queue/message-queue.constants';
|
|
||||||
import { TwentyORMGlobalManager } from 'src/engine/twenty-orm/twenty-orm-global.manager';
|
import { TwentyORMGlobalManager } from 'src/engine/twenty-orm/twenty-orm-global.manager';
|
||||||
import { MessageChannelWorkspaceEntity } from 'src/modules/messaging/common/standard-objects/message-channel.workspace-entity';
|
import { MessageChannelWorkspaceEntity } from 'src/modules/messaging/common/standard-objects/message-channel.workspace-entity';
|
||||||
import { MessagingTelemetryService } from 'src/modules/messaging/monitoring/services/messaging-telemetry.service';
|
import { MessagingTelemetryService } from 'src/modules/messaging/monitoring/services/messaging-telemetry.service';
|
||||||
|
|
||||||
|
export const MESSAGING_MESSAGE_CHANNEL_SYNC_STATUS_MONITORING_CRON_PATTERN =
|
||||||
|
'2/10 * * * *'; //Every 10 minutes, starting at 2 minutes past the hour
|
||||||
|
|
||||||
@Processor(MessageQueue.cronQueue)
|
@Processor(MessageQueue.cronQueue)
|
||||||
export class MessagingMessageChannelSyncStatusMonitoringCronJob {
|
export class MessagingMessageChannelSyncStatusMonitoringCronJob {
|
||||||
private readonly logger = new Logger(
|
private readonly logger = new Logger(
|
||||||
@ -28,6 +32,10 @@ export class MessagingMessageChannelSyncStatusMonitoringCronJob {
|
|||||||
private readonly twentyORMGlobalManager: TwentyORMGlobalManager,
|
private readonly twentyORMGlobalManager: TwentyORMGlobalManager,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
|
@SentryCronMonitor(
|
||||||
|
MessagingMessageChannelSyncStatusMonitoringCronJob.name,
|
||||||
|
MESSAGING_MESSAGE_CHANNEL_SYNC_STATUS_MONITORING_CRON_PATTERN,
|
||||||
|
)
|
||||||
@Process(MessagingMessageChannelSyncStatusMonitoringCronJob.name)
|
@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...');
|
||||||
|
Loading…
Reference in New Issue
Block a user