Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,9 @@ import {
import { CodeTransformTelemetryState } from '../../telemetry/codeTransformTelemetryState'
import DependencyVersions from '../../models/dependencies'
import { getStringHash } from '../../../shared/utilities/textUtilities'
import { getVersionData } from '../../../codewhisperer/service/transformByQ/transformMavenHandler'
import AdmZip from 'adm-zip'
import { AuthError } from '../../../auth/sso/server'
import {
setMaven,
openBuildLogFile,
parseBuildFile,
validateSQLMetadataFile,
Expand Down Expand Up @@ -321,12 +319,6 @@ export class GumbyController {
telemetryJavaVersion = JDKToTelemetryValue(javaVersion) as CodeTransformJavaSourceVersionsAllowed
}
telemetry.record({ codeTransformLocalJavaVersion: telemetryJavaVersion })

await setMaven()
const versionInfo = await getVersionData()
const mavenVersionInfoMessage = `${versionInfo[0]} (${transformByQState.getMavenName()})`
telemetry.record({ buildSystemVersion: mavenVersionInfoMessage })
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was always recording [undefined, undefined] since the user hasn't selected a project to transform at this point. Plus, we already emit this in the totalRunTime metric at the very end of a transformation anyway.


return validProjects
})
return validProjects
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,7 @@ export async function startJob(uploadId: string) {
target: { language: targetLanguageVersion }, // always JDK17
},
})
getLogger().info('CodeTransformation: called startJob API successfully')
if (response.$response.requestId) {
transformByQState.setJobFailureMetadata(` (request ID: ${response.$response.requestId})`)
}
Expand Down Expand Up @@ -670,6 +671,7 @@ export async function pollTransformationJob(jobId: string, validStates: string[]
})
}
transformByQState.setPolledJobStatus(status)
getLogger().info(`CodeTransformation: polled job status = ${status}`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI: getLogger() now has a "topic" feature so you can do this at the top of the module:

const logger = getLogger('CodeTransformation')

then logger.info() will prepend the topic name.


const errorMessage = response.transformationJob.reason
if (errorMessage !== undefined) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { spawnSync } from 'child_process' // eslint-disable-line no-restricted-i
import { CodeTransformBuildCommand, telemetry } from '../../../shared/telemetry/telemetry'
import { CodeTransformTelemetryState } from '../../../amazonqGumby/telemetry/codeTransformTelemetryState'
import { ToolkitError } from '../../../shared/errors'
import { writeLogs } from './transformFileHandler'
import { setMaven, writeLogs } from './transformFileHandler'
import { throwIfCancelled } from './transformApiHandler'

// run 'install' with either 'mvnw.cmd', './mvnw', or 'mvn' (if wrapper exists, we use that, otherwise we use regular 'mvn')
Expand Down Expand Up @@ -108,6 +108,8 @@ function copyProjectDependencies(dependenciesFolder: FolderInfo, modulePath: str
}

export async function prepareProjectDependencies(dependenciesFolder: FolderInfo, rootPomPath: string) {
await setMaven()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to set the Maven to use (mvn, mvnw, mvnw.cmd) just before the local build happens to ensure we're using the correct Maven executable.

getLogger().info('CodeTransformation: running Maven copy-dependencies')
try {
copyProjectDependencies(dependenciesFolder, rootPomPath)
} catch (err) {
Expand All @@ -117,6 +119,7 @@ export async function prepareProjectDependencies(dependenciesFolder: FolderInfo,
)
}

getLogger().info('CodeTransformation: running Maven install')
try {
installProjectDependencies(dependenciesFolder, rootPomPath)
} catch (err) {
Expand All @@ -134,9 +137,9 @@ export async function prepareProjectDependencies(dependenciesFolder: FolderInfo,

export async function getVersionData() {
const baseCommand = transformByQState.getMavenName() // will be one of: 'mvnw.cmd', './mvnw', 'mvn'
const modulePath = transformByQState.getProjectPath()
const projectPath = transformByQState.getProjectPath()
const args = ['-v']
const spawnResult = spawnSync(baseCommand, args, { cwd: modulePath, shell: true, encoding: 'utf-8' })
const spawnResult = spawnSync(baseCommand, args, { cwd: projectPath, shell: true, encoding: 'utf-8' })

let localMavenVersion: string | undefined = ''
let localJavaVersion: string | undefined = ''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ export class DiffModel {
}

const changedFiles = parsePatch(diffContents)
getLogger().info('CodeTransformation: parsed patch file successfully')
// path to the directory containing copy of the changed files in the transformed project
const pathToTmpSrcDir = this.copyProject(pathToWorkspace, changedFiles)
transformByQState.setProjectCopyFilePath(pathToTmpSrcDir)
Expand Down Expand Up @@ -401,6 +402,7 @@ export class ProposedTransformationExplorer {
pathToArchive
)

getLogger().info('CodeTransformation: downloaded results successfully')
// Update downloaded artifact size
exportResultsArchiveSize = (await fs.promises.stat(pathToArchive)).size

Expand Down Expand Up @@ -532,6 +534,7 @@ export class ProposedTransformationExplorer {

vscode.commands.registerCommand('aws.amazonq.transformationHub.reviewChanges.acceptChanges', async () => {
telemetry.codeTransform_submitSelection.run(() => {
getLogger().info('CodeTransformation: accepted changes')
diffModel.saveChanges()
telemetry.record({
codeTransformSessionId: CodeTransformTelemetryState.instance.getSessionId(),
Expand Down Expand Up @@ -585,6 +588,7 @@ export class ProposedTransformationExplorer {

vscode.commands.registerCommand('aws.amazonq.transformationHub.reviewChanges.rejectChanges', async () => {
await telemetry.codeTransform_submitSelection.run(async () => {
getLogger().info('CodeTransformation: rejected changes')
diffModel.rejectChanges()
await reset()
telemetry.record({
Expand Down
Loading