Skip to content

Commit 84a12a8

Browse files
authored
feat(codeTransform): upload error logs #4325
Problem We run Maven shell commands to install and copy-dependencies and a javap shell command to determine a project's java version, and although we know the frequency of failures for these commands, we have insufficient insight into why they failed. Solution - Add the error message to existing metrics when these commands fail. - Add error logs to our upload ZIP so that we can process it in the backend.
1 parent d933144 commit 84a12a8

File tree

9 files changed

+237
-102
lines changed

9 files changed

+237
-102
lines changed

package-lock.json

Lines changed: 25 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4269,7 +4269,7 @@
42694269
},
42704270
"devDependencies": {
42714271
"@aws-sdk/types": "^3.13.1",
4272-
"@aws-toolkits/telemetry": "^1.0.176",
4272+
"@aws-toolkits/telemetry": "^1.0.182",
42734273
"@aws/fully-qualified-names": "^2.1.1",
42744274
"@cspotcode/source-map-support": "^0.8.1",
42754275
"@sinonjs/fake-timers": "^10.0.2",

src/amazonqFeatureDev/util/download.ts

Lines changed: 0 additions & 48 deletions
This file was deleted.

src/codewhisperer/commands/startTransformByQ.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
convertDateToTimestamp,
2323
getOpenProjects,
2424
validateProjectSelection,
25+
getVersionData,
2526
} from '../service/transformByQHandler'
2627
import { QuickPickItem } from 'vscode'
2728
import path from 'path'
@@ -328,11 +329,20 @@ export async function postTransformationJob(userInputState: UserInputState) {
328329
const durationInMs = calculateTotalLatency(codeTransformTelemetryState.getStartTime())
329330
const resultStatusMessage = codeTransformTelemetryState.getResultStatus()
330331

332+
const versionInfoWrapper = await getVersionData('mvnw', transformByQState.getProjectPath())
333+
let mavenVersionInfoMessage = versionInfoWrapper[0]
334+
let javaVersionInfoMessage = versionInfoWrapper[1]
335+
const versionInfo = await getVersionData('mvn', transformByQState.getProjectPath())
336+
mavenVersionInfoMessage += ` (mvnw) -- ${versionInfo[0]} (mvn)`
337+
javaVersionInfoMessage += ` (mvnw) -- ${versionInfo[1]} (mvn)`
338+
331339
// Note: IntelliJ implementation of ResultStatusMessage includes additional metadata such as jobId.
332340
telemetry.codeTransform_totalRunTime.emit({
333341
codeTransformSessionId: codeTransformTelemetryState.getSessionId(),
334342
codeTransformResultStatusMessage: resultStatusMessage,
335343
codeTransformRunTimeLatency: durationInMs,
344+
codeTransformLocalMavenVersion: mavenVersionInfoMessage,
345+
codeTransformLocalJavaVersion: javaVersionInfoMessage,
336346
result: resultStatusMessage === 'JobCompletedSuccessfully' ? MetadataResult.Pass : MetadataResult.Fail,
337347
reason: resultStatusMessage,
338348
})

src/codewhisperer/models/constants.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,11 @@ export const dependencyDisclaimer =
324324

325325
export const dependencyFolderName = 'transformation_dependencies_temp_'
326326

327+
export const installErrorMessage =
328+
'Failed to execute Maven install. It is possible that the upload does not include all dependencies. We will still attempt to complete the transformation.'
329+
327330
export const dependencyErrorMessage =
328-
'Failed to execute Maven. It is possible that the upload does not include all dependencies. We will still attempt to complete the transformation.'
331+
'Failed to execute Maven copy-dependencies. It is possible that the upload does not include all dependencies. We will still attempt to complete the transformation.'
329332

330333
export const planIntroductionMessage =
331334
'We reviewed your Java JAVA_VERSION_HERE application and generated a transformation plan. Any code changes made to your application will be done in the sandbox so as to not interfere with your working repository. Once the transformation job is done, we will share the new code which you can review before acccepting the code changes. In the meantime, you can work on your codebase and invoke Q Chat to answer questions about your codebase.'
@@ -338,6 +341,8 @@ export const JDK11VersionNumber = '55'
338341

339342
export const numMillisecondsPerSecond = 1000
340343

344+
export const maxBufferSize = 1024 * 1024 // this is 1MB, the default max buffer size for stdout for spawnSync
345+
341346
export const transformByQStateRunningMessage = 'running'
342347

343348
export const transformByQStateCancellingMessage = 'cancelling'

src/codewhisperer/models/model.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,8 @@ export class TransformByQState {
280280

281281
private jobFailureErrorMessage: string = ''
282282

283+
private errorLog: string = ''
284+
283285
public isNotStarted() {
284286
return this.transformByQState === TransformByQStatus.NotStarted
285287
}
@@ -360,6 +362,14 @@ export class TransformByQState {
360362
return this.jobFailureErrorMessage
361363
}
362364

365+
public getErrorLog() {
366+
return this.errorLog
367+
}
368+
369+
public appendToErrorLog(message: string) {
370+
this.errorLog += `${message}\n\n`
371+
}
372+
363373
public setToNotStarted() {
364374
this.transformByQState = TransformByQStatus.NotStarted
365375
}

0 commit comments

Comments
 (0)