Skip to content

Commit 8655a2d

Browse files
fix(amazonq): Fix for incorrect TriggerToResponseLatencyMilliseconds values in JetBrains telemetry (aws#6260)
* fix(amazonq): adding changelog * fix(amazonq): Fix for incorrect TriggerToResponseLatencyMilliseconds values in JetBrains telemetry --------- Co-authored-by: chungjac <chungjac@amazon.com>
1 parent 811197e commit 8655a2d

File tree

1 file changed

+16
-5
lines changed
  • plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/model

1 file changed

+16
-5
lines changed

plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/model/CodeWhispererModel.kt

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -219,20 +219,31 @@ data class LatencyContext(
219219

220220
var firstRequestId: String = "",
221221
) {
222-
fun getCodeWhispererEndToEndLatency() = TimeUnit.NANOSECONDS.toMillis(
223-
codewhispererEndToEndEnd - codewhispererEndToEndStart
224-
).toDouble()
222+
fun getCodeWhispererEndToEndLatency(): Double {
223+
// Guard against uninitialized timestamps which would result in incorrect latency values
224+
if (codewhispererEndToEndStart == 0L || codewhispererEndToEndEnd == 0L) {
225+
return 0.0
226+
}
227+
return TimeUnit.NANOSECONDS.toMillis(
228+
codewhispererEndToEndEnd - codewhispererEndToEndStart
229+
).toDouble()
230+
}
225231

226232
// For auto-trigger it's from the time when last char typed
227233
// for manual-trigger it's from the time when last trigger action happened(alt + c)
228-
fun getPerceivedLatency(triggerType: CodewhispererTriggerType) =
229-
if (triggerType == CodewhispererTriggerType.OnDemand) {
234+
fun getPerceivedLatency(triggerType: CodewhispererTriggerType): Double {
235+
// Guard against uninitialized timestamps which would result in incorrect latency values
236+
if (codewhispererEndToEndEnd == 0L) {
237+
return 0.0
238+
}
239+
return if (triggerType == CodewhispererTriggerType.OnDemand) {
230240
getCodeWhispererEndToEndLatency()
231241
} else {
232242
TimeUnit.NANOSECONDS.toMillis(
233243
codewhispererEndToEndEnd - CodeWhispererAutoTriggerService.getInstance().timeAtLastCharTyped
234244
).toDouble()
235245
}
246+
}
236247
}
237248

238249
data class TryExampleRowContext(

0 commit comments

Comments
 (0)