Skip to content

Commit d62ae9c

Browse files
committed
Removing the statusCode from UTG telemetry
1 parent f86d1cb commit d62ae9c

File tree

3 files changed

+12
-21
lines changed

3 files changed

+12
-21
lines changed

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonqCodeTest/CodeWhispererUTGChatManager.kt

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ class CodeWhispererUTGChatManager(val project: Project, private val cs: Coroutin
136136
val errorMessage = getTelemetryErrorMessage(e, CodeWhispererConstants.FeatureName.TEST_GENERATION)
137137
throw CodeTestException(
138138
"CreateTestJobError: $errorMessage",
139-
statusCode,
140139
"CreateTestJobError",
141140
message("testgen.error.generic_technical_error_message")
142141
)
@@ -195,7 +194,6 @@ class CodeWhispererUTGChatManager(val project: Project, private val cs: Coroutin
195194
// If job status is Completed and has no ShortAnswer then there might be some issue in the backend.
196195
throw CodeTestException(
197196
"TestGenFailedError: " + message("testgen.message.failed"),
198-
500,
199197
"TestGenFailedError",
200198
message("testgen.error.generic_technical_error_message")
201199
)
@@ -208,14 +206,13 @@ class CodeWhispererUTGChatManager(val project: Project, private val cs: Coroutin
208206
if (testGenerationResponse.testGenerationJob().shortAnswer() != null) {
209207
shortAnswer = parseShortAnswerString(testGenerationResponse.testGenerationJob().shortAnswer())
210208
if (shortAnswer.stopIteration == "true") {
211-
throw CodeTestException("TestGenFailedError: ${shortAnswer.planSummary}", 400, "TestGenFailedError", shortAnswer.planSummary)
209+
throw CodeTestException("TestGenFailedError: ${shortAnswer.planSummary}", "TestGenFailedError", shortAnswer.planSummary)
212210
}
213211
}
214212

215213
// If job status is Failed and has no ShortAnswer then there might be some issue in the backend.
216214
throw CodeTestException(
217215
"TestGenFailedError: " + message("testgen.message.failed"),
218-
500,
219216
"TestGenFailedError",
220217
message("testgen.error.generic_technical_error_message")
221218
)
@@ -230,7 +227,7 @@ class CodeWhispererUTGChatManager(val project: Project, private val cs: Coroutin
230227
if (previousIterationContext == null && testGenerationResponse.testGenerationJob().shortAnswer() != null) {
231228
shortAnswer = parseShortAnswerString(testGenerationResponse.testGenerationJob().shortAnswer())
232229
if (shortAnswer.stopIteration == "true") {
233-
throw CodeTestException("TestGenFailedError: ${shortAnswer.planSummary}", 400, "TestGenFailedError", shortAnswer.planSummary)
230+
throw CodeTestException("TestGenFailedError: ${shortAnswer.planSummary}", "TestGenFailedError", shortAnswer.planSummary)
234231
}
235232
codeTestChatHelper.updateAnswer(
236233
CodeTestChatMessageContent(
@@ -264,7 +261,6 @@ class CodeWhispererUTGChatManager(val project: Project, private val cs: Coroutin
264261
LOG.error(e) { "ExportResultArchive failed: ${e.message}" }
265262
throw CodeTestException(
266263
"ExportResultsArchiveError: ${e.message}",
267-
500,
268264
"ExportResultsArchiveError",
269265
message("testgen.error.generic_technical_error_message")
270266
)
@@ -530,7 +526,7 @@ class CodeWhispererUTGChatManager(val project: Project, private val cs: Coroutin
530526
} catch (e: Exception) {
531527
// Add an answer for displaying error message
532528
val errorMessage = when {
533-
e is CodeTestException && e.statusCode == 400 &&
529+
e is CodeTestException &&
534530
e.message?.startsWith("CreateTestJobError: Maximum") == true ->
535531
message("testgen.error.maximum_generations_reach")
536532

@@ -557,7 +553,6 @@ class CodeWhispererUTGChatManager(val project: Project, private val cs: Coroutin
557553
result = if (e.message == message("testgen.message.cancelled")) MetricResult.Cancelled else MetricResult.Failed,
558554
reason = (e as CodeTestException).code ?: "DefaultError",
559555
reasonDesc = if (e.message == message("testgen.message.cancelled")) "${e.code}: ${e.message}" else e.message,
560-
httpStatusCode = e.statusCode.toString(),
561556
perfClientLatency = (Instant.now().toEpochMilli() - session.startTimeOfTestGeneration),
562557
isCodeBlockSelected = session.isCodeBlockSelected,
563558
artifactsUploadDuration = session.artifactUploadDuration,

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonqCodeTest/controller/CodeTestChatController.kt

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,7 @@ class CodeTestChatController(
291291
credentialStartUrl = getStartUrl(project),
292292
result = MetricResult.Succeeded,
293293
perfClientLatency = (Instant.now().toEpochMilli() - session.startTimeOfTestGeneration),
294-
requestId = id,
295-
httpStatusCode = "200"
294+
requestId = id
296295
)
297296
}
298297
session.isGeneratingTests = false
@@ -604,8 +603,7 @@ class CodeTestChatController(
604603
artifactsUploadDuration = session.artifactUploadDuration,
605604
buildPayloadBytes = session.srcPayloadSize,
606605
buildZipFileBytes = session.srcZipFileSize,
607-
requestId = session.startTestGenerationRequestId,
608-
httpStatusCode = "200"
606+
requestId = session.startTestGenerationRequestId
609607
)
610608
codeTestChatHelper.addAnswer(
611609
CodeTestChatMessageContent(
@@ -799,8 +797,7 @@ class CodeTestChatController(
799797
artifactsUploadDuration = session.artifactUploadDuration,
800798
buildPayloadBytes = session.srcPayloadSize,
801799
buildZipFileBytes = session.srcZipFileSize,
802-
requestId = session.startTestGenerationRequestId,
803-
httpStatusCode = "200"
800+
requestId = session.startTestGenerationRequestId
804801
)
805802
sessionCleanUp(message.tabId)
806803
}

plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/codetest/CodeTestException.kt

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,29 @@ import software.aws.toolkits.resources.message
77

88
open class CodeTestException(
99
override val message: String?,
10-
val statusCode: Int = 400,
1110
val code: String? = "DefaultError",
1211
val uiMessage: String? = message(
1312
"testgen.error.generic_error_message"
1413
),
1514
) : RuntimeException()
1615

1716
internal fun noFileOpenError(): Nothing =
18-
throw CodeTestException(message("codewhisperer.codescan.no_file_open"), 400, "ProjectZipError")
17+
throw CodeTestException(message("codewhisperer.codescan.no_file_open"), "ProjectZipError")
1918

2019
internal fun fileTooLarge(): Nothing =
21-
throw CodeTestException(message("codewhisperer.codescan.file_too_large_telemetry"), 400, "ProjectZipError")
20+
throw CodeTestException(message("codewhisperer.codescan.file_too_large_telemetry"), "ProjectZipError")
2221

2322
internal fun cannotFindFile(errorMessage: String, filepath: String): Nothing =
2423
error(message("codewhisperer.codescan.file_not_found", filepath, errorMessage))
2524

2625
internal fun cannotFindValidFile(errorMessage: String): Nothing =
27-
throw CodeTestException(errorMessage, 400, "ProjectZipError")
26+
throw CodeTestException(errorMessage, "ProjectZipError")
2827

2928
internal fun cannotFindBuildArtifacts(errorMessage: String): Nothing =
30-
throw CodeTestException(errorMessage, 400, "ProjectZipError")
29+
throw CodeTestException(errorMessage, "ProjectZipError")
3130

3231
internal fun invalidSourceZipError(): Nothing =
33-
throw CodeTestException(message("codewhisperer.codescan.invalid_source_zip_telemetry"), 400, "InvalidSourceZipError")
32+
throw CodeTestException(message("codewhisperer.codescan.invalid_source_zip_telemetry"), "InvalidSourceZipError")
3433

3534
fun testGenStoppedError(): Nothing =
36-
throw CodeTestException(message("testgen.message.cancelled"), 400, "TestGenCancelled", message("testgen.message.cancelled"))
35+
throw CodeTestException(message("testgen.message.cancelled"), "TestGenCancelled", message("testgen.message.cancelled"))

0 commit comments

Comments
 (0)