Skip to content

Commit

Permalink
fix(logs): improve log observability
Browse files Browse the repository at this point in the history
  • Loading branch information
uladkasach committed Jun 29, 2024
1 parent ee7a06b commit 48a6bbc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
16 changes: 10 additions & 6 deletions src/logic/withAsyncTaskExecutionLifecycleEnqueue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export const withAsyncTaskExecutionLifecycleEnqueue = <
// if the task already exists, check that its in a queueable state
if (taskFound?.status === AsyncTaskStatus.QUEUED) {
log.debug(
'skipped adding task to queue. reason: task is already queued',
'enqueueTask.progress: skipped adding task to queue. reason: task is already queued',
{
task: taskFound,
},
Expand All @@ -91,7 +91,7 @@ export const withAsyncTaskExecutionLifecycleEnqueue = <
}
if (taskFound?.status === AsyncTaskStatus.ATTEMPTED) {
log.debug(
'skipped adding task to queue. reason: task is already being attempted from queue',
'enqueueTask.progress: skipped adding task to queue. reason: task is already being attempted from queue',
{
task: taskFound,
},
Expand All @@ -100,7 +100,7 @@ export const withAsyncTaskExecutionLifecycleEnqueue = <
}
if (taskFound?.status === AsyncTaskStatus.FULFILLED) {
log.debug(
'skipped adding task to queue. reason: task was already fulfilled',
'enqueueTask.progress: skipped adding task to queue. reason: task was already fulfilled',
{
task: taskFound,
},
Expand All @@ -109,7 +109,7 @@ export const withAsyncTaskExecutionLifecycleEnqueue = <
}
if (taskFound?.status === AsyncTaskStatus.CANCELED) {
log.debug(
'skipped adding task to queue. reason: task was already canceled',
'enqueueTask.progress: skipped adding task to queue. reason: task was already canceled',
{
task: taskFound,
},
Expand All @@ -125,10 +125,10 @@ export const withAsyncTaskExecutionLifecycleEnqueue = <
...taskReadyToQueue,
status: AsyncTaskStatus.QUEUED,
};
log.debug('adding task to queue', {
log.debug('enqueueTask.progress: adding task to queue', {
task: taskToQueue,
queue: { type: queue.type },
});

await (async () => {
// support sqs queues natively
if (queue.type === 'SQS')
Expand All @@ -146,6 +146,10 @@ export const withAsyncTaskExecutionLifecycleEnqueue = <
{ queue },
);
})();
log.debug('enqueueTask.progress: added task to queue', {
task: taskToQueue,
queue: { type: queue.type },
});

// and save that it has been queued
return await dao.upsert(
Expand Down
4 changes: 2 additions & 2 deletions src/logic/withAsyncTaskExecutionLifecycleExecute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,14 @@ export const withAsyncTaskExecutionLifecycleExecute = <
// check that the task has not already been fulfilled and is not canceled; if either are true, warn and exit
if (foundTask.status === AsyncTaskStatus.FULFILLED) {
log.warn(
'attempted to execute a task that has already been fulfilled. skipping',
'executeTask.progress: attempted to execute a task that has already been fulfilled. skipping',
{ task: foundTask },
);
return { task: foundTask };
}
if (foundTask.status === AsyncTaskStatus.CANCELED) {
log.warn(
'attempted to execute a task that has already been canceled. skipping',
'executeTask.progress: attempted to execute a task that has already been canceled. skipping',
{ task: foundTask },
);
return { task: foundTask };
Expand Down

0 comments on commit 48a6bbc

Please sign in to comment.