Skip to content

Commit 612f2b8

Browse files
authored
feat(dispatch): enhance logging for workflow job events and dispatch status (#4964)
This is a small enhancement to the workflow dispatch lambda to help with debugging. Without this change it's hard to find which event gets dispatched to which queue and why. We ran this in production for several weeks without problems.
1 parent 391a65f commit 612f2b8

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

lambdas/functions/webhook/src/runners/dispatch.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ async function handleWorkflowJob(
3636
body: `Workflow job not queued, not dispatching to queue.`,
3737
};
3838
}
39+
40+
logger.debug(
41+
`Processing workflow job event - Repository: ${body.repository.full_name}, ` +
42+
`Job ID: ${body.workflow_job.id}, Job Name: ${body.workflow_job.name}, ` +
43+
`Run ID: ${body.workflow_job.run_id}, Labels: ${JSON.stringify(body.workflow_job.labels)}`,
44+
);
3945
// sort the queuesConfig by order of matcher config exact match, with all true matches lined up ahead.
4046
matcherConfig.sort((a, b) => {
4147
return a.matcherConfig.exactMatch === b.matcherConfig.exactMatch ? 0 : a.matcherConfig.exactMatch ? -1 : 1;
@@ -51,7 +57,10 @@ async function handleWorkflowJob(
5157
queueId: queue.id,
5258
repoOwnerType: body.repository.owner.type,
5359
});
54-
logger.info(`Successfully dispatched job for ${body.repository.full_name} to the queue ${queue.id}`);
60+
logger.info(
61+
`Successfully dispatched job for ${body.repository.full_name} to the queue ${queue.id} - ` +
62+
`Job ID: ${body.workflow_job.id}, Job Name: ${body.workflow_job.name}, Run ID: ${body.workflow_job.run_id}`,
63+
);
5564
return {
5665
statusCode: 201,
5766
body: `Successfully queued job for ${body.repository.full_name} to the queue ${queue.id}`,
@@ -61,7 +70,9 @@ async function handleWorkflowJob(
6170
const notAcceptedErrorMsg = `Received event contains runner labels '${body.workflow_job.labels}' from '${
6271
body.repository.full_name
6372
}' that are not accepted.`;
64-
logger.warn(notAcceptedErrorMsg);
73+
logger.warn(
74+
`${notAcceptedErrorMsg} - Job ID: ${body.workflow_job.id}, Job Name: ${body.workflow_job.name}, Run ID: ${body.workflow_job.run_id}`,
75+
);
6576
return { statusCode: 202, body: notAcceptedErrorMsg };
6677
}
6778

0 commit comments

Comments
 (0)