Skip to content

Commit a949ac0

Browse files
authored
fix: emit error code on failed user messages (aws#2322)
1 parent aa1a482 commit a949ac0

File tree

4 files changed

+8
-2
lines changed

4 files changed

+8
-2
lines changed

server/aws-lsp-codewhisperer/src/language-server/agenticChat/agenticChatController.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3479,7 +3479,8 @@ export class AgenticChatController implements ChatHandlers {
34793479
metric.metric.requestIds = [requestID]
34803480
metric.metric.cwsprChatMessageId = errorMessageId
34813481
metric.metric.cwsprChatConversationId = conversationId
3482-
await this.#telemetryController.emitAddMessageMetric(tabId, metric.metric, 'Failed', errorMessage)
3482+
const errorCode = err.code ?? ''
3483+
await this.#telemetryController.emitAddMessageMetric(tabId, metric.metric, 'Failed', errorMessage, errorCode)
34833484

34843485
if (isUsageLimitError(err)) {
34853486
if (this.#paidTierMode !== 'paidtier') {

server/aws-lsp-codewhisperer/src/language-server/chat/telemetry/chatTelemetryController.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,8 @@ export class ChatTelemetryController {
298298
tabId: string,
299299
metric: Partial<CombinedConversationEvent>,
300300
result?: string,
301-
errorMessage?: string
301+
errorMessage?: string,
302+
errorCode?: string
302303
) {
303304
const conversationId = this.getConversationId(tabId)
304305
// Store the customization value associated with the message
@@ -355,6 +356,7 @@ export class ChatTelemetryController {
355356
experimentName: metric.experimentName,
356357
userVariation: metric.userVariation,
357358
errorMessage: errorMessage,
359+
errorCode: errorCode,
358360
}
359361
)
360362
}

server/aws-lsp-codewhisperer/src/shared/telemetry/telemetryService.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -860,6 +860,7 @@ describe('TelemetryService', () => {
860860
cwsprChatPinnedFolderContextCount: undefined,
861861
cwsprChatPinnedPromptContextCount: undefined,
862862
errorMessage: undefined,
863+
errorCode: undefined,
863864
},
864865
})
865866
})

server/aws-lsp-codewhisperer/src/shared/telemetry/telemetryService.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,7 @@ export class TelemetryService {
566566
experimentName?: string
567567
userVariation?: string
568568
errorMessage?: string
569+
errorCode?: string
569570
}>
570571
) {
571572
const timeBetweenChunks = params.timeBetweenChunks?.slice(0, 100)
@@ -620,6 +621,7 @@ export class TelemetryService {
620621
experimentName: additionalParams.experimentName,
621622
userVariation: additionalParams.userVariation,
622623
errorMessage: additionalParams.errorMessage,
624+
errorCode: additionalParams.errorCode,
623625
},
624626
})
625627
}

0 commit comments

Comments
 (0)