From e5a0b9d1e73c3e1470b0df096d0d1693c3e397e2 Mon Sep 17 00:00:00 2001 From: Jacob Chung Date: Thu, 17 Apr 2025 11:40:34 -0700 Subject: [PATCH 1/2] try catch for telemetry error --- .../controllers/chat/telemetryHelper.ts | 42 ++++++++++++------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/packages/core/src/codewhispererChat/controllers/chat/telemetryHelper.ts b/packages/core/src/codewhispererChat/controllers/chat/telemetryHelper.ts index 51029d2e2fc..48e0d560fb1 100644 --- a/packages/core/src/codewhispererChat/controllers/chat/telemetryHelper.ts +++ b/packages/core/src/codewhispererChat/controllers/chat/telemetryHelper.ts @@ -218,27 +218,39 @@ export class CWCTelemetryHelper { } public recordToolUseSuggested(toolUse: ToolUse, messageId: string) { - telemetry.amazonq_toolUseSuggested.emit({ - result: 'Succeeded', - cwsprChatConversationId: messageId, - cwsprChatConversationType: 'AgenticChatWithToolUse', - credentialStartUrl: AuthUtil.instance.startUrl, - cwsprToolName: toolUse.name ?? '', - cwsprToolUseId: toolUse.toolUseId ?? '', - }) + try { + telemetry.amazonq_toolUseSuggested.run((span) => { + span.record({ + result: 'Succeeded', + cwsprChatConversationId: messageId, + cwsprChatConversationType: 'AgenticChatWithToolUse', + credentialStartUrl: AuthUtil.instance.startUrl, + cwsprToolName: toolUse.name ?? '', + cwsprToolUseId: toolUse.toolUseId ?? '', + }) + }) + } catch (e: any) { + getLogger().info('Unable to record amazonq_toolUseSuggested telemetry') + } } public recordInteractionWithAgenticChat( interactionType: AgenticChatInteractionType, message: AcceptResponseMessage | CustomFormActionMessage | StopResponseMessage ) { - telemetry.amazonq_interactWithAgenticChat.emit({ - cwsprAgenticChatInteractionType: interactionType, - result: 'Succeeded', - cwsprChatConversationId: this.getConversationId(message.tabID ?? '') ?? '', - cwsprChatConversationType: 'AgenticChat', - credentialStartUrl: AuthUtil.instance.startUrl, - }) + try { + telemetry.amazonq_interactWithAgenticChat.run((span) => { + span.record({ + cwsprAgenticChatInteractionType: interactionType, + result: 'Succeeded', + cwsprChatConversationId: this.getConversationId(message.tabID ?? '') ?? '', + cwsprChatConversationType: 'AgenticChat', + credentialStartUrl: AuthUtil.instance.startUrl, + }) + }) + } catch (e: any) { + getLogger().info('Unable to record amazonq_interactWithAgenticChat telemetry') + } } public recordInteractWithMessage( From 9a973325fbfae420de7aa9daec5bcdbdbe3a1773 Mon Sep 17 00:00:00 2001 From: Jacob Chung Date: Thu, 17 Apr 2025 11:52:37 -0700 Subject: [PATCH 2/2] logger error instead of info --- .../src/codewhispererChat/controllers/chat/telemetryHelper.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/core/src/codewhispererChat/controllers/chat/telemetryHelper.ts b/packages/core/src/codewhispererChat/controllers/chat/telemetryHelper.ts index 48e0d560fb1..862d8f1207e 100644 --- a/packages/core/src/codewhispererChat/controllers/chat/telemetryHelper.ts +++ b/packages/core/src/codewhispererChat/controllers/chat/telemetryHelper.ts @@ -230,7 +230,7 @@ export class CWCTelemetryHelper { }) }) } catch (e: any) { - getLogger().info('Unable to record amazonq_toolUseSuggested telemetry') + getLogger().error('Unable to record amazonq_toolUseSuggested telemetry') } } @@ -249,7 +249,7 @@ export class CWCTelemetryHelper { }) }) } catch (e: any) { - getLogger().info('Unable to record amazonq_interactWithAgenticChat telemetry') + getLogger().error('Unable to record amazonq_interactWithAgenticChat telemetry') } }