Skip to content
Merged
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
20 changes: 16 additions & 4 deletions packages/core/src/amazonq/messages/chatMessageDuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,28 @@ export class AmazonQChatMessageDuration {

// TODO: handle onContextCommand round trip time
if (metrics.trigger !== 'onContextCommand') {
const editorReceivedMessage = durationFrom('chatMessageSent', 'editorReceivedMessage')
const featureReceivedMessage = durationFrom('editorReceivedMessage', 'featureReceivedMessage')
const messageDisplayed = durationFrom('featureReceivedMessage', 'messageDisplayed')
let reasonDesc = undefined

/**
* Temporary include more information about outliers so that we can find out if the messages
* aren't being sent or the user is actually doing a different chat flow
*/
if ([editorReceivedMessage, featureReceivedMessage].some((val) => val > 30000 || val < -30000)) {
reasonDesc = JSON.stringify(metrics.events)
}
telemetry.amazonq_chatRoundTrip.emit({
amazonqChatMessageSentTime: metrics.events.chatMessageSent ?? -1,
amazonqEditorReceivedMessageMs: durationFrom('chatMessageSent', 'editorReceivedMessage') ?? -1,
amazonqFeatureReceivedMessageMs:
durationFrom('editorReceivedMessage', 'featureReceivedMessage') ?? -1,
amazonqMessageDisplayedMs: durationFrom('featureReceivedMessage', 'messageDisplayed') ?? -1,
amazonqEditorReceivedMessageMs: editorReceivedMessage ?? -1,
amazonqFeatureReceivedMessageMs: featureReceivedMessage ?? -1,
amazonqMessageDisplayedMs: messageDisplayed ?? -1,
source: metrics.trigger,
duration: totalDuration,
result: 'Succeeded',
traceId: metrics.traceId,
...(reasonDesc !== undefined ? { reasonDesc } : {}),
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm pretty sure that if reasonDesc is undefined it just gets dropped. So would reasonDesc: reasonDesc work?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We want it to be undefined so that we don't send information when its not needed

})
}

Expand Down
Loading