-
Notifications
You must be signed in to change notification settings - Fork 735
telemetry(amazonq): Add id2 and logging for createUpload metrics #6857
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -384,20 +384,24 @@ export async function uploadArtifactToS3( | |
| headersObj['x-amz-server-side-encryption-aws-kms-key-id'] = resp.kmsKeyArn | ||
| } | ||
|
|
||
| let requestId: string | undefined = undefined | ||
| let id2: string | undefined = undefined | ||
| let responseCode: string = '' | ||
|
|
||
| try { | ||
| const response = await request.fetch('PUT', resp.uploadUrl, { | ||
| body: readFileSync(fileName), | ||
| headers: resp?.requestHeaders ?? headersObj, | ||
| }).response | ||
| logger.debug(`StatusCode: ${response.status}, Text: ${response.statusText}`) | ||
| requestId = response.headers?.get('x-amz-request-id') ?? undefined | ||
| id2 = response.headers?.get('x-amz-id-2') ?? undefined | ||
| responseCode = response.status.toString() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not great that all of this is placed in the business logic for a feature. This kind of thing should live in And clearly, it's not easy to get right, since this PR is already fixing a bug related to it. Yet this bug fix won't be shared with other similar code that needs to make requests (even if it's specific to S3 PUT). |
||
| } catch (error) { | ||
| if (span && error instanceof RequestError) { | ||
| const requestId = error.response.headers.get('x-amz-request-id') ?? undefined | ||
| span.record({ | ||
| requestId: requestId, | ||
| requestServiceType: 's3', | ||
| httpStatusCode: error.code.toString(), | ||
| }) | ||
| requestId = error.response.headers.get('x-amz-request-id') ?? undefined | ||
| id2 = error.response.headers.get('x-amz-id-2') ?? undefined | ||
| responseCode = error.code.toString() | ||
| } | ||
| let errorMessage = '' | ||
| const isCodeScan = featureUseCase === FeatureUseCase.CODE_SCAN | ||
|
|
@@ -419,6 +423,16 @@ export async function uploadArtifactToS3( | |
| ChatSessionManager.Instance.getSession().startTestGenerationRequestId = error.requestId | ||
| } | ||
| throw isCodeScan ? new UploadArtifactToS3Error(errorMessage) : new UploadTestArtifactToS3Error(errorMessage) | ||
| } finally { | ||
| getLogger().debug(`Upload to S3 response details: x-amz-request-id: ${requestId}, x-amz-id-2: ${id2}`) | ||
| if (span) { | ||
| span.record({ | ||
| requestId: requestId, | ||
| requestId2: id2, | ||
| requestServiceType: 's3', | ||
| httpStatusCode: responseCode, | ||
| }) | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible this exceeds a request size limit? Should it be streamed?