diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index e017dce6fed..5497bc430c0 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -27,7 +27,7 @@ mockitoKotlin = "5.4.0" mockk = "1.13.17" nimbus-jose-jwt = "9.40" node-gradle = "7.0.2" -telemetryGenerator = "1.0.310" +telemetryGenerator = "1.0.312" testLogger = "4.0.0" testRetry = "1.5.10" # test-only; platform provides slf4j transitively at runtime diff --git a/plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/codescan/CodeWhispererCodeScanException.kt b/plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/codescan/CodeWhispererCodeScanException.kt index a50aac1a773..2146ed80ff0 100644 --- a/plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/codescan/CodeWhispererCodeScanException.kt +++ b/plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/codescan/CodeWhispererCodeScanException.kt @@ -12,6 +12,7 @@ open class CodeWhispererCodeFixException(override val message: String?) : Runtim open class CodeWhispererCodeScanServerException( override val message: String?, val requestId: String?, + val id2: String?, val requestServiceType: String?, val httpStatusCode: String?, ) : RuntimeException() @@ -37,9 +38,10 @@ internal fun fileTooLarge(): Nothing = internal fun codeScanServerException( errorMessage: String, requestId: String? = null, + id2: String? = null, requestServiceType: String? = null, httpStatusCode: String? = null, -): Nothing = throw CodeWhispererCodeScanServerException(errorMessage, requestId, requestServiceType, httpStatusCode) +): Nothing = throw CodeWhispererCodeScanServerException(errorMessage, requestId, id2, requestServiceType, httpStatusCode) internal fun invalidSourceZipError(): Nothing = throw CodeWhispererCodeScanException(message("codewhisperer.codescan.invalid_source_zip_telemetry")) diff --git a/plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/util/CodeWhispererZipUploadManager.kt b/plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/util/CodeWhispererZipUploadManager.kt index f964092a8d5..48744b123eb 100644 --- a/plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/util/CodeWhispererZipUploadManager.kt +++ b/plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/util/CodeWhispererZipUploadManager.kt @@ -64,6 +64,7 @@ class CodeWhispererZipUploadManager(private val project: Project) { var requestId: String? = null var requestServiceType: String? = null var httpStatusCode: String? = null + var id2: String? = null try { // Throw error if zipFile is invalid. if (!zipFile.exists()) { @@ -78,7 +79,7 @@ class CodeWhispererZipUploadManager(private val project: Project) { val url = createUploadUrlResponse.uploadUrl() LOG.debug { "$featureUseCase: Uploading $artifactType using the presigned URL." } - uploadArtifactToS3( + val connection = uploadArtifactToS3( url, createUploadUrlResponse.uploadId(), zipFile, @@ -87,6 +88,8 @@ class CodeWhispererZipUploadManager(private val project: Project) { createUploadUrlResponse.requestHeaders(), featureUseCase ) + requestId = connection?.getHeaderField("x-amz-request-id") + id2 = connection?.getHeaderField("x-amz-id-2") return createUploadUrlResponse } catch (e: Exception) { result = MetricResult.Failed @@ -96,10 +99,12 @@ class CodeWhispererZipUploadManager(private val project: Project) { requestId = e.requestId requestServiceType = e.requestServiceType httpStatusCode = e.httpStatusCode + id2 = e.id2 } throw e } finally { if (featureUseCase == CodeWhispererConstants.FeatureName.CODE_REVIEW) { + LOG.info("Upload to S3 details: x-amz-request-id: $requestId and x-amz-id-2: $id2") AmazonqTelemetry.createUpload( amazonqConversationId = "", amazonqUploadIntent = if (taskType == CodeWhispererConstants.UploadTaskType.SCAN_PROJECT) { @@ -113,6 +118,7 @@ class CodeWhispererZipUploadManager(private val project: Project) { duration = (System.currentTimeMillis() - startTime).toDouble(), credentialStartUrl = getStartUrl(project), requestId = requestId, + requestId2 = id2, requestServiceType = requestServiceType, httpStatusCode = httpStatusCode ) @@ -129,7 +135,7 @@ class CodeWhispererZipUploadManager(private val project: Project) { kmsArn: String?, requestHeaders: Map?, featureUseCase: CodeWhispererConstants.FeatureName, - ) { + ) : HttpURLConnection? { var connection: HttpURLConnection? = null RetryableOperation().execute( operation = { @@ -167,6 +173,7 @@ class CodeWhispererZipUploadManager(private val project: Project) { codeScanServerException( "CreateUploadUrlException: $errorMessage", connection?.getHeaderField("x-amz-request-id"), + connection?.getHeaderField("x-amz-id-2"), "s3", (e as? HttpRequests.HttpStatusException)?.statusCode.toString() ) @@ -180,6 +187,7 @@ class CodeWhispererZipUploadManager(private val project: Project) { } } ) + return connection } fun createUploadUrl(