From 7651320b702ae7add2f9e28faa1038369337baf6 Mon Sep 17 00:00:00 2001 From: Derek Sonnenberg Date: Fri, 7 Jun 2024 12:57:51 -0500 Subject: [PATCH] refactor(s3-data-source): add debug logs PE-6106 --- src/data/s3-data-source.ts | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/data/s3-data-source.ts b/src/data/s3-data-source.ts index 166fafd3..1537e7b8 100644 --- a/src/data/s3-data-source.ts +++ b/src/data/s3-data-source.ts @@ -71,6 +71,12 @@ export class S3DataSource implements ContiguousDataSource { // Bucket: this.s3Bucket, // Key: `${this.s3Prefix}/${id}`, // }); + + log.debug('Fetching S3 metadata', { + id, + bucket: this.s3Bucket, + prefix: this.s3Prefix, + }); const head = await axios.head( `${AWS_ENDPOINT}/${this.s3Bucket}/${this.s3Prefix}/${id}`, { validateStatus: () => true }, @@ -92,6 +98,22 @@ export class S3DataSource implements ContiguousDataSource { streamResponsePayload: true, }); + const payloadContentTypeS3MetaDataTag = 'x-amz-meta-payload-content-type'; + const sourceContentType = + head.headers?.[payloadContentTypeS3MetaDataTag] ?? response.ContentType; + + log.debug('S3 response', { + id, + response: { + ContentLength: response.ContentLength, + ContentType: response.ContentType, + }, + payload: { + range, + sourceContentType, + }, + }); + const requestOriginAndHopsHeaders: { [key: string]: string } = {}; let hops; let origin; @@ -114,9 +136,6 @@ export class S3DataSource implements ContiguousDataSource { if (response.Body === undefined) { throw new Error('Body missing from S3 response'); } - const payloadContentTypeS3MetaDataTag = 'x-amz-meta-payload-content-type'; - const sourceContentType = - head.headers?.[payloadContentTypeS3MetaDataTag] ?? response.ContentType; return { stream: response.Body as Readable,