Skip to content

Commit 68eb050

Browse files
authored
Added metric to check ssm failure count (#3575)
1 parent 7e0b849 commit 68eb050

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

jetbrains-gateway/src/software/aws/toolkits/jetbrains/gateway/CawsConnectionProvider.kt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,13 +166,16 @@ class CawsConnectionProvider : GatewayConnectionProvider {
166166

167167
val pluginPath = "$IDE_BACKEND_DIR/plugins/${AwsToolkit.pluginPath().fileName}"
168168
var retries = 3
169+
val startTimeToCheckInstallation = System.currentTimeMillis()
170+
169171
val toolkitInstallSettings: ToolkitInstallSettings? = coroutineScope {
170172
while (retries > 0) {
171173
indicator.checkCanceled()
172174
val pluginIsInstalled = executor.remoteDirectoryExists(
173175
pluginPath,
174176
timeout = Duration.ofSeconds(15)
175177
)
178+
176179
when (pluginIsInstalled) {
177180
null -> {
178181
if (retries == 1) {
@@ -188,9 +191,19 @@ class CawsConnectionProvider : GatewayConnectionProvider {
188191
}
189192
}
190193
} as ToolkitInstallSettings?
194+
191195
toolkitInstallSettings ?: let {
192196
// environment is non-responsive to SSM; restart
193197
LOG.warn { "Restarting $envId since it appears unresponsive to SSM Run-Command" }
198+
val timeTakenToCheckInstallation = System.currentTimeMillis() - startTimeToCheckInstallation
199+
CodecatalystTelemetry.devEnvironmentWorkflowStatistic(
200+
project = null,
201+
userId = userId,
202+
result = TelemetryResult.Failed,
203+
codecatalystDevEnvironmentWorkflowStep = "ToolkitInstallationSSMCheck",
204+
codecatalystDevEnvironmentWorkflowError = "Timeout/Unknown error while connecting to Dev Env via SSM",
205+
duration = timeTakenToCheckInstallation.toDouble()
206+
)
194207
coroutineScope {
195208
launchChildIOBackground {
196209
environmentActions.stopEnvironment()

0 commit comments

Comments
 (0)