Skip to content

Commit

Permalink
refactor(s3-data-source): add debug logs PE-6106
Browse files Browse the repository at this point in the history
  • Loading branch information
fedellen authored and djwhitt committed Jun 7, 2024
1 parent 677da80 commit 7651320
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions src/data/s3-data-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand All @@ -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;
Expand All @@ -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,
Expand Down

0 comments on commit 7651320

Please sign in to comment.