Add workspace id in job logs (#19764)
Cannot currently investigate spikes
This commit is contained in:
+6
-2
@@ -111,16 +111,20 @@ export class BullMQDriver
|
||||
async (job) => {
|
||||
// TODO: Correctly support for job.id
|
||||
const timeStart = performance.now();
|
||||
const workspaceId = job.data?.workspaceId;
|
||||
const workspaceSuffix = workspaceId
|
||||
? ` [workspace=${workspaceId}]`
|
||||
: '';
|
||||
|
||||
this.logger.log(
|
||||
`Processing job ${job.id} with name ${job.name} on queue ${queueName}`,
|
||||
`Processing job ${job.id} with name ${job.name} on queue ${queueName}${workspaceSuffix}`,
|
||||
);
|
||||
await handler({ data: job.data, id: job.id ?? '', name: job.name });
|
||||
const timeEnd = performance.now();
|
||||
const executionTime = timeEnd - timeStart;
|
||||
|
||||
this.logger.log(
|
||||
`Job ${job.id} with name ${job.name} processed on queue ${queueName} in ${executionTime.toFixed(2)}ms`,
|
||||
`Job ${job.id} with name ${job.name} processed on queue ${queueName} in ${executionTime.toFixed(2)}ms${workspaceSuffix}`,
|
||||
);
|
||||
},
|
||||
workerOptions,
|
||||
|
||||
+6
-1
@@ -1,4 +1,4 @@
|
||||
import { Scope } from '@nestjs/common';
|
||||
import { Logger, Scope } from '@nestjs/common';
|
||||
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
@@ -24,6 +24,8 @@ import { WorkflowTriggerType } from 'src/modules/workflow/workflow-trigger/types
|
||||
|
||||
@Processor({ queueName: MessageQueue.workflowQueue, scope: Scope.REQUEST })
|
||||
export class RunWorkflowJob {
|
||||
private readonly logger = new Logger(RunWorkflowJob.name);
|
||||
|
||||
constructor(
|
||||
private readonly workflowCommonWorkspaceService: WorkflowCommonWorkspaceService,
|
||||
private readonly codeStepBuildService: CodeStepBuildService,
|
||||
@@ -39,6 +41,9 @@ export class RunWorkflowJob {
|
||||
lastExecutedStepId,
|
||||
workspaceId,
|
||||
}: RunWorkflowJobData): Promise<void> {
|
||||
this.logger.log(
|
||||
`Running workflow run ${workflowRunId} in workspace ${workspaceId}`,
|
||||
);
|
||||
const authContext = buildSystemAuthContext(workspaceId);
|
||||
|
||||
await this.globalWorkspaceOrmManager.executeInWorkspaceContext(async () => {
|
||||
|
||||
Reference in New Issue
Block a user