Skip to content

Commit d4a28eb

Browse files
authored
telemetry(amazonq): Add more information for outlier chat round trips (#5944)
## Problem It's hard to diagnose why we sometimes get some extreme values for a chat round trip. One idea is that some remote instances might be hosted in a different region and that's causing the increased values in some rare instances ## Solution Add the stringified version to the reasonDesc field temporarily so that we can get more information. This would look like: ``` '{"chatMessageSent":1730994444010,"editorReceivedMessage":1730994444011,"featureReceivedMessage":1730994444013,"messageDisplayed":1730994459698}', ``` ## Additional info The numbers picked were pretty arbitrary `(x > 30000 || x < -30000)` but it should give us a sampling of 50+ examples in the next week. After that we can revert this code since we should have all the data we need to see if this is the issue
1 parent fee4a43 commit d4a28eb

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

packages/core/src/amazonq/messages/chatMessageDuration.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,28 @@ export class AmazonQChatMessageDuration {
8383

8484
// TODO: handle onContextCommand round trip time
8585
if (metrics.trigger !== 'onContextCommand') {
86+
const editorReceivedMessage = durationFrom('chatMessageSent', 'editorReceivedMessage')
87+
const featureReceivedMessage = durationFrom('editorReceivedMessage', 'featureReceivedMessage')
88+
const messageDisplayed = durationFrom('featureReceivedMessage', 'messageDisplayed')
89+
let reasonDesc = undefined
90+
91+
/**
92+
* Temporary include more information about outliers so that we can find out if the messages
93+
* aren't being sent or the user is actually doing a different chat flow
94+
*/
95+
if ([editorReceivedMessage, featureReceivedMessage].some((val) => val > 30000 || val < -30000)) {
96+
reasonDesc = JSON.stringify(metrics.events)
97+
}
8698
telemetry.amazonq_chatRoundTrip.emit({
8799
amazonqChatMessageSentTime: metrics.events.chatMessageSent ?? -1,
88-
amazonqEditorReceivedMessageMs: durationFrom('chatMessageSent', 'editorReceivedMessage') ?? -1,
89-
amazonqFeatureReceivedMessageMs:
90-
durationFrom('editorReceivedMessage', 'featureReceivedMessage') ?? -1,
91-
amazonqMessageDisplayedMs: durationFrom('featureReceivedMessage', 'messageDisplayed') ?? -1,
100+
amazonqEditorReceivedMessageMs: editorReceivedMessage ?? -1,
101+
amazonqFeatureReceivedMessageMs: featureReceivedMessage ?? -1,
102+
amazonqMessageDisplayedMs: messageDisplayed ?? -1,
92103
source: metrics.trigger,
93104
duration: totalDuration,
94105
result: 'Succeeded',
95106
traceId: metrics.traceId,
107+
...(reasonDesc !== undefined ? { reasonDesc } : {}),
96108
})
97109
}
98110

0 commit comments

Comments
 (0)