Skip to content

Commit

Permalink
Adding Telemetry metric for files out of workspace scope.
Browse files Browse the repository at this point in the history
  • Loading branch information
ashishrp-aws committed Jan 8, 2025
1 parent 26fe595 commit 46de10c
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 50 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"mergeReports": "ts-node ./scripts/mergeReports.ts"
},
"devDependencies": {
"@aws-toolkits/telemetry": "^1.0.289",
"@aws-toolkits/telemetry": "^1.0.293",
"@playwright/browser-chromium": "^1.43.1",
"@stylistic/eslint-plugin": "^2.11.0",
"@types/he": "^1.2.3",
Expand Down
18 changes: 15 additions & 3 deletions packages/core/src/amazonqTest/chat/controller/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ export class TestController {
TelemetryHelper.instance.sendTestGenerationToolkitEvent(
session,
true,
true,
isCancel ? 'Cancelled' : 'Failed',
session.startTestGenerationRequestId,
performance.now() - session.testGenerationStartTime,
Expand Down Expand Up @@ -456,7 +457,14 @@ export class TestController {
unsupportedMessage = `<span style="color: #EE9D28;">&#9888;<b>I'm sorry, but /test only supports Python and Java</b><br></span> I will still generate a suggestion below.`
}
this.messenger.sendMessage(unsupportedMessage, tabID, 'answer')
await this.onCodeGeneration(session, message.prompt, tabID, fileName, filePath)
await this.onCodeGeneration(
session,
message.prompt,
tabID,
fileName,
filePath,
workspaceFolder !== undefined
)
} else {
this.messenger.sendCapabilityCard({ tabID })
this.messenger.sendMessage(testGenSummaryMessage(fileName), message.tabID, 'answer-part')
Expand Down Expand Up @@ -722,6 +730,7 @@ export class TestController {
TelemetryHelper.instance.sendTestGenerationToolkitEvent(
session,
true,
true,
'Succeeded',
session.startTestGenerationRequestId,
session.latencyOfTestGeneration,
Expand Down Expand Up @@ -799,7 +808,8 @@ export class TestController {
message: string,
tabID: string,
fileName: string,
filePath: string
filePath: string,
fileInWorkspace: boolean
) {
try {
// TODO: Write this entire gen response to basiccommands and call here.
Expand Down Expand Up @@ -827,7 +837,8 @@ export class TestController {
tabID,
randomUUID.toString(),
triggerPayload,
fileName
fileName,
fileInWorkspace
)
} finally {
this.messenger.sendChatInputEnabled(tabID, true)
Expand All @@ -843,6 +854,7 @@ export class TestController {
TelemetryHelper.instance.sendTestGenerationToolkitEvent(
session,
true,
true,
'Succeeded',
session.startTestGenerationRequestId,
session.latencyOfTestGeneration,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ export class Messenger {
tabID: string,
triggerID: string,
triggerPayload: TriggerPayload,
fileName: string
fileName: string,
fileInWorkspace: boolean
) {
let message = ''
let messageId = response.$metadata.requestId ?? ''
Expand Down Expand Up @@ -277,6 +278,7 @@ export class Messenger {
TelemetryHelper.instance.sendTestGenerationToolkitEvent(
session,
false,
fileInWorkspace,
'Cancelled',
messageId,
performance.now() - session.testGenerationStartTime,
Expand All @@ -291,6 +293,7 @@ export class Messenger {
TelemetryHelper.instance.sendTestGenerationToolkitEvent(
session,
false,
fileInWorkspace,
'Succeeded',
messageId,
performance.now() - session.testGenerationStartTime
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/codewhisperer/util/telemetryHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export class TelemetryHelper {
public sendTestGenerationToolkitEvent(
session: Session,
isSupportedLanguage: boolean,
isFileInWorkspace: boolean,
result: 'Succeeded' | 'Failed' | 'Cancelled',
requestId?: string,
perfClientLatency?: number,
Expand All @@ -81,6 +82,7 @@ export class TelemetryHelper {
cwsprChatProgrammingLanguage: session.fileLanguage ?? 'plaintext',
hasUserPromptSupplied: session.hasUserPromptSupplied,
isSupportedLanguage: isSupportedLanguage,
isFileInWorkspace: isFileInWorkspace,
result: result,
artifactsUploadDuration: artifactsUploadDuration,
buildPayloadBytes: buildPayloadBytes,
Expand Down
Loading

0 comments on commit 46de10c

Please sign in to comment.