Skip to content

Commit

Permalink
HARMONY-1914: Reduce a significant amount of the logging noise at the…
Browse files Browse the repository at this point in the history
… debug level. Use the silly log level when needing these detailed messages.
  • Loading branch information
chris-durbin committed Sep 30, 2024
1 parent 9a840ad commit f687db0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ export async function makeWorkScheduleRequest(serviceID: string): Promise<void>
*/
export async function getWorkFromQueue(serviceID: string, reqLogger: Logger): Promise<WorkItemData | null> {
const queueUrl = getQueueUrlForService(serviceID);
reqLogger.debug(`Short polling for work from queue ${queueUrl} for service ${serviceID}`);
reqLogger.silly(`Short polling for work from queue ${queueUrl} for service ${serviceID}`);

const queue = getQueueForUrl(queueUrl);
if (!queue) {
Expand All @@ -197,20 +197,19 @@ export async function getWorkFromQueue(serviceID: string, reqLogger: Logger): Pr
// get a message from the service queue without using long-polling
let queueItem = await queue.getMessage(0);
if (!queueItem) {
reqLogger.debug(`No work found on queue ${queueUrl} for service ${serviceID} - requesting work from scheduler`);
reqLogger.silly(`No work found on queue ${queueUrl} for service ${serviceID} - requesting work from scheduler`);
// put a message on the scheduler queue asking it to schedule some WorkItems for this service
await makeWorkScheduleRequest(serviceID);

// this actually does nothing outside of tests since the scheduler pod will be running
await processSchedulerQueue(reqLogger);

// long poll for work before giving up
reqLogger.debug(`Long polling for work on queue ${queueUrl} for service ${serviceID}`);
reqLogger.silly(`Long polling for work on queue ${queueUrl} for service ${serviceID}`);
queueItem = await queue.getMessage();
}

if (queueItem) {
// reqLogger.debug(`Found work item ${JSON.stringify(queueItem, null, 2)} on queue ${queueUrl}`);
reqLogger.debug(`Found work item on queue ${queueUrl}`);
// normally we would process this before deleting the message, but we instead are relying on
// our retry mechanism to requeue the message if the worker fails
Expand Down Expand Up @@ -242,7 +241,7 @@ export async function getWorkFromQueue(serviceID: string, reqLogger: Logger): Pr
reqLogger.error(`Error updating work item status to running: ${err.message}`);
}
} else {
reqLogger.debug(`No work found on queue ${queueUrl} for service ${serviceID}`);
reqLogger.silly(`No work found on queue ${queueUrl} for service ${serviceID}`);
}

return null;
Expand Down
4 changes: 2 additions & 2 deletions services/harmony/app/routers/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ function logged(fn: RequestHandler): RequestHandler {
req.context.logger = child;
const startTime = new Date().getTime();
try {
child.debug('Invoking middleware');
child.silly('Invoking middleware');
return fn(req, res, next);
} finally {
const msTaken = new Date().getTime() - startTime;
child.debug('Completed middleware', { durationMs: msTaken });
child.silly('Completed middleware', { durationMs: msTaken });
if (req.context.logger === child) {
// Other middlewares may have changed the logger. This generally happens
// when `next()` is an async call that the middleware doesn't await. Note
Expand Down

0 comments on commit f687db0

Please sign in to comment.