Skip to content

Commit d9fbe85

Browse files
jumskinel
andauthored
fix(edge-worker): refine task logging experience for (#167) (#178)
* fix(edge-worker): refine task logging experience for (#167) * refactor(logging): improve task logging levels and visibility for better debugging Refine task logging levels by moving detailed execution logs from ExecutionController to MessageExecutor, demote controller logs from info to debug, and elevate task lifecycle, retry, and error logs to appropriate levels. Enhance overall visibility of task events and failures for easier troubleshooting. --------- Co-authored-by: Renaud (Nel) Morvan <nel@w3fu.com>
1 parent 2447031 commit d9fbe85

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed

.changeset/stupid-showers-speak.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
'@pgflow/edge-worker': patch
3+
---
4+
5+
Refine task logging levels for better visibility
6+
7+
- Move detailed execution logs from ExecutionController to MessageExecutor
8+
- Demote controller-level logs from info to debug
9+
- Promote task execution, retry, and error logs from debug to appropriate levels (info/error)
10+
- Improve visibility of task lifecycle events and failures

pkgs/edge-worker/src/core/ExecutionController.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ export class ExecutionController<TMessage extends IMessage> {
2727
async start(record: TMessage) {
2828
const executor = this.createExecutor(record, this.signal);
2929

30-
this.logger.info(`Scheduling execution of task ${executor.msgId}`);
30+
this.logger.debug(`Scheduling execution of task ${executor.msgId}`);
3131

3232
return await this.promiseQueue.add(async () => {
3333
try {
3434
this.logger.debug(`Executing task ${executor.msgId}...`);
3535
await executor.execute();
36-
this.logger.info(`Execution successful for ${executor.msgId}`);
36+
this.logger.debug(`Execution successful for ${executor.msgId}`);
3737
} catch (error) {
3838
this.logger.error(`Execution failed for ${executor.msgId}`, error);
3939
throw error;

pkgs/edge-worker/src/queue/MessageExecutor.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ export class MessageExecutor<TPayload extends Json> {
4747
// Check if already aborted before starting
4848
this.signal.throwIfAborted();
4949

50-
this.logger.debug(`Executing task ${this.msgId}...`);
50+
this.logger.info(`Executing task ${this.msgId}...`);
5151
await this.messageHandler(this.record.message!);
5252

53-
this.logger.debug(
53+
this.logger.info(
5454
`Task ${this.msgId} completed successfully, archiving...`
5555
);
5656
await this.queue.archive(this.msgId);
@@ -70,12 +70,12 @@ export class MessageExecutor<TPayload extends Json> {
7070
*/
7171
private async handleExecutionError(error: unknown) {
7272
if (error instanceof Error && error.name === 'AbortError') {
73-
this.logger.debug(`Aborted execution for ${this.msgId}`);
73+
this.logger.info(`Aborted execution for ${this.msgId}`);
7474
// Do not throw - the worker was aborted and stopping,
7575
// the message will reappear after the visibility timeout
7676
// and be picked up by another worker
7777
} else {
78-
this.logger.debug(`Task ${this.msgId} failed with error: ${error}`);
78+
this.logger.error(`Task ${this.msgId} failed with error: ${error}`);
7979
await this.retryOrArchive();
8080
}
8181
}
@@ -92,11 +92,13 @@ export class MessageExecutor<TPayload extends Json> {
9292
const retryDelay = this.calculateRetryDelay(retryAttempt, this.retryConfig);
9393

9494
// adjust visibility timeout for message to appear after retryDelay
95-
this.logger.debug(`Retrying ${this.msgId} in ${retryDelay} seconds (retry attempt ${retryAttempt})`);
95+
this.logger.info(
96+
`Retrying ${this.msgId} in ${retryDelay} seconds (retry attempt ${retryAttempt})`
97+
);
9698
await this.queue.setVt(this.msgId, retryDelay);
9799
} else {
98100
// archive message forever and stop processing it
99-
this.logger.debug(`Archiving ${this.msgId} forever`);
101+
this.logger.info(`Archiving ${this.msgId} forever`);
100102
await this.queue.archive(this.msgId);
101103
}
102104
}

0 commit comments

Comments
 (0)