From 8059674733a93f2c57d20b54f1fc83a1cd12fbcd Mon Sep 17 00:00:00 2001 From: Kathleen Koh Date: Wed, 13 Mar 2024 17:53:09 +0800 Subject: [PATCH] fix: adding duration logs for virus scan file download --- .../modules/submission/submission.service.ts | 20 ++++++------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/src/app/modules/submission/submission.service.ts b/src/app/modules/submission/submission.service.ts index 9fda84768f..17c177b0a1 100644 --- a/src/app/modules/submission/submission.service.ts +++ b/src/app/modules/submission/submission.service.ts @@ -401,13 +401,13 @@ export const downloadCleanFile = (cleanFileKey: string, versionId: string) => { message: 'Successfully downloaded file from S3', meta: logMeta, }) - resolve(buffer) - }) - const timeDownloadEnd = Date.now() + const timeDownloadEnd = Date.now() + logger.info({ + message: 'Duration of file download from S3', + meta: { ...logMeta, time: timeDownloadEnd - timeDownloadStart }, + }) - logger.info({ - message: 'Duration of file download from S3', - meta: { ...logMeta, time: timeDownloadEnd - timeDownloadStart }, + resolve(buffer) }) readStream.on('error', (error) => { @@ -426,14 +426,6 @@ export const downloadCleanFile = (cleanFileKey: string, versionId: string) => { ) } -// statsdClient.distribution( -// 'formsg.submissions.virusScanFile.duration', -// duration, -// { -// rating: `${rating}`, -// }, -// ) - /** * Helper function to trigger virus scanning and download clean file. * @param response quarantined attachment response from storage submissions v2.1+.