Skip to content

Commit f771659

Browse files
committed
chore: updated task logging
1 parent a6bb024 commit f771659

File tree

2 files changed

+39
-10
lines changed

2 files changed

+39
-10
lines changed

src/discovery/Discovery.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,9 @@ class Discovery {
838838
}
839839
// Only create if it doesn't exist
840840
if (taskExisting != null) return;
841+
this.logger.info(
842+
`Scheduling new discovery for vertex with gestaltId ${gestaltIdEncoded}`,
843+
);
841844
await this.taskManager.scheduleTask(
842845
{
843846
handlerId: this.discoverVertexHandlerId,
@@ -1097,6 +1100,9 @@ class Discovery {
10971100
}
10981101
if (taskExisting != null) continue;
10991102
// Schedule a new task
1103+
this.logger.info(
1104+
`Scheduling new discovery for vertex with gestaltId ${gestaltIdEncoded}`,
1105+
);
11001106
await this.taskManager.scheduleTask(
11011107
{
11021108
handlerId: this.discoverVertexHandlerId,

src/tasks/TaskManager.ts

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -916,8 +916,10 @@ class TaskManager {
916916
tran.queueSuccess(() => {
917917
this.triggerQueuing();
918918
});
919+
this.schedulerLogger.debug(
920+
`Queued Task ${taskIdEncoded} with handler ${taskData.handlerId}`,
921+
);
919922
});
920-
this.schedulerLogger.debug(`Queued Task ${taskIdEncoded}`);
921923
}
922924

923925
/**
@@ -1015,7 +1017,9 @@ class TaskManager {
10151017
try {
10161018
await this.requeueTask(taskId);
10171019
} catch (e) {
1018-
this.logger.error(`Failed Requeuing Task ${taskIdEncoded}`);
1020+
this.logger.error(
1021+
`Failed Requeuing Task ${taskIdEncoded} with handler ${taskData.handlerId}`,
1022+
);
10191023
// This is an unrecoverable error
10201024
throw new tasksErrors.ErrorTaskRequeue(taskIdEncoded, {
10211025
cause: e,
@@ -1024,15 +1028,24 @@ class TaskManager {
10241028
} else {
10251029
if (succeeded) {
10261030
taskLogger.debug('Succeeded');
1031+
taskLogger.info(
1032+
`Task ${tasksUtils.encodeTaskId(
1033+
taskId,
1034+
)} succeeded with handler ${taskData.handlerId}`,
1035+
);
10271036
} else {
1028-
taskLogger.warn(`Failed - Reason: ${String(taskReason)}`);
1037+
taskLogger.warn(
1038+
`Failed - Reason: ${String(taskReason)}, Handler: ${
1039+
taskData.handlerId
1040+
}`,
1041+
);
10291042
}
10301043
// GC the task before dispatching events
10311044
try {
10321045
await this.gcTask(taskId);
10331046
} catch (e) {
10341047
this.logger.error(
1035-
`Failed Garbage Collecting Task ${taskIdEncoded}`,
1048+
`Failed Garbage Collecting Task ${taskIdEncoded} with handler ${taskData.handlerId}`,
10361049
);
10371050
// This is an unrecoverable error
10381051
throw new tasksErrors.ErrorTaskGarbageCollection(
@@ -1075,7 +1088,9 @@ class TaskManager {
10751088
abortController,
10761089
);
10771090
this.activePromises.set(taskIdEncoded, activePromiseCancellable);
1078-
this.queueLogger.debug(`Started Task ${taskIdEncoded}`);
1091+
this.queueLogger.debug(
1092+
`Started Task ${taskIdEncoded} with handler ${taskData.handlerId}`,
1093+
);
10791094
});
10801095
});
10811096
}
@@ -1096,7 +1111,9 @@ class TaskManager {
10961111
taskId.toBuffer(),
10971112
]);
10981113
if (taskData == null) return;
1099-
this.logger.debug(`Garbage Collecting Task ${taskIdEncoded}`);
1114+
this.logger.debug(
1115+
`Garbage Collecting Task ${taskIdEncoded} with handler ${taskData.handlerId}`,
1116+
);
11001117
const taskScheduleTime = taskData.timestamp + taskData.delay;
11011118
await tran.del([
11021119
...this.tasksPathDbPath,
@@ -1116,7 +1133,9 @@ class TaskManager {
11161133
taskIdBuffer,
11171134
]);
11181135
await tran.del([...this.tasksTaskDbPath, taskId.toBuffer()]);
1119-
this.logger.debug(`Garbage Collected Task ${taskIdEncoded}`);
1136+
this.logger.debug(
1137+
`Garbage Collected Task ${taskIdEncoded} with handler ${taskData.handlerId}`,
1138+
);
11201139
}
11211140

11221141
protected async requeueTask(
@@ -1128,7 +1147,6 @@ class TaskManager {
11281147
}
11291148
const taskIdBuffer = taskId.toBuffer();
11301149
const taskIdEncoded = tasksUtils.encodeTaskId(taskId);
1131-
this.logger.debug(`Requeuing Task ${taskIdEncoded}`);
11321150
await this.lockTask(tran, taskId);
11331151
const taskData = await tran.get<TaskData>([
11341152
...this.tasksTaskDbPath,
@@ -1137,6 +1155,9 @@ class TaskManager {
11371155
if (taskData == null) {
11381156
throw new tasksErrors.ErrorTaskMissing(taskIdEncoded);
11391157
}
1158+
this.logger.debug(
1159+
`Requeuing Task ${taskIdEncoded} with handler ${taskData.handlerId}`,
1160+
);
11401161
// Put task into the active index
11411162
// this index will be used to retry tasks if they don't finish
11421163
await tran.del([...this.tasksActiveDbPath, taskIdBuffer]);
@@ -1150,7 +1171,9 @@ class TaskManager {
11501171
],
11511172
null,
11521173
);
1153-
this.logger.debug(`Requeued Task ${taskIdEncoded}`);
1174+
this.logger.debug(
1175+
`Requeued Task ${taskIdEncoded} with handler ${taskData.handlerId}`,
1176+
);
11541177
}
11551178

11561179
protected async cancelTask(taskId: TaskId, cancelReason: any): Promise<void> {
@@ -1244,7 +1267,7 @@ class TaskManager {
12441267
// Removing task from active index
12451268
await tran.del([...this.tasksActiveDbPath, ...kP]);
12461269
this.logger.warn(
1247-
`Moving Task ${taskIdEncoded} from Active to Queued`,
1270+
`Moving Task ${taskIdEncoded} with handler ${taskData.handlerId} from Active to Queued`,
12481271
);
12491272
}
12501273
}

0 commit comments

Comments
 (0)