Skip to content

Commit

Permalink
chore: adding duration logs for virus scan file download
Browse files Browse the repository at this point in the history
  • Loading branch information
kathleenkhy committed Mar 13, 2024
1 parent 41cbe5a commit 711fd01
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/app/modules/submission/submission.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {
ParsedClearFormFieldResponse,
} from '../../../types/api'
import { aws as AwsConfig } from '../../config/config'
// import { statsdClient } from '../../config/datadog-statsd-client'
import { createLoggerWithLabel } from '../../config/logger'
import getPendingSubmissionModel from '../../models/pending_submission.server.model'
import getSubmissionModel, {
Expand Down Expand Up @@ -385,6 +386,7 @@ export const downloadCleanFile = (cleanFileKey: string, versionId: string) => {
})
.createReadStream()

const timeDownloadStart = Date.now()
logger.info({
message: 'File download from S3 has started',
meta: logMeta,
Expand All @@ -401,6 +403,12 @@ export const downloadCleanFile = (cleanFileKey: string, versionId: string) => {
})
resolve(buffer)
})
const timeDownloadEnd = Date.now()

logger.info({
message: 'Duration of file download from S3',
meta: { ...logMeta, time: timeDownloadEnd - timeDownloadStart },
})

readStream.on('error', (error) => {
reject(error)
Expand All @@ -418,6 +426,14 @@ 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+.
Expand Down

0 comments on commit 711fd01

Please sign in to comment.