Revert "Added reopenFileAfterIdeRestart metric for monolith"

This reverts commit 101f99bc157d547d1b0c6f0b6ee70d391a6f5f07.

GitOrigin-RevId: 6bc091491367fb4cc6cd6ff86feaa0d15f2c6045
This commit is contained in:
Alexey Kryuchkov
2025-07-24 15:28:32 +00:00
committed by intellij-monorepo-bot
parent 4bf9d40b0f
commit 776484d649
4 changed files with 2 additions and 87 deletions
@@ -134,8 +134,7 @@ public final class BaseCommandProvider implements CommandProvider {
Map.entry(CloseLookupCommand.PREFIX, CloseLookupCommand::new),
Map.entry(OpenProblemViewPanelCommand.PREFIX, OpenProblemViewPanelCommand::new),
Map.entry(AssertProblemsViewCountCommand.PREFIX, AssertProblemsViewCountCommand::new),
Map.entry(DetectProjectLeaksCommand.PREFIX, DetectProjectLeaksCommand::new),
Map.entry(WaitForReOpenedFileCommand.PREFIX, WaitForReOpenedFileCommand::new)
Map.entry(DetectProjectLeaksCommand.PREFIX, DetectProjectLeaksCommand::new)
);
}
}
@@ -21,7 +21,6 @@ import com.intellij.openapi.vfs.LocalFileSystem
import com.intellij.openapi.vfs.VirtualFile
import com.jetbrains.performancePlugin.PerformanceTestingBundle
import com.jetbrains.performancePlugin.utils.DaemonCodeAnalyzerListener
import com.jetbrains.performancePlugin.utils.HighlightingTestUtil
import com.sampullara.cli.Args
import io.opentelemetry.api.trace.Span
import kotlinx.coroutines.Dispatchers
@@ -104,7 +103,7 @@ class OpenFileCommand(text: String, line: Int) : PerformanceCommandCoroutineAdap
.openFile(file = file, options = FileEditorOpenOptions(requestFocus = true))
if (useWaitForCodeAnalysisCode(options)) {
HighlightingTestUtil.waitForAnalysisWithNewApproach(project, spanRef, timeout, suppressErrors)
waitForAnalysisWithNewApproach(project, spanRef, timeout, suppressErrors)
openFileSpan!!.end()
return
}
@@ -1,55 +0,0 @@
package com.jetbrains.performancePlugin.commands
import com.intellij.openapi.diagnostic.logger
import com.intellij.openapi.fileEditor.FileEditorManager
import com.intellij.openapi.fileEditor.FileEditorManagerListener
import com.intellij.openapi.ui.playback.PlaybackContext
import com.intellij.openapi.util.io.toNioPathOrNull
import com.intellij.openapi.vfs.VirtualFile
import com.jetbrains.performancePlugin.PerformanceTestSpan
import com.jetbrains.performancePlugin.utils.HighlightingTestUtil
import io.opentelemetry.api.trace.Span
import io.opentelemetry.context.Context
import kotlinx.coroutines.sync.Mutex
import org.jetbrains.annotations.NonNls
class WaitForReOpenedFileCommand(text: String, line: Int) : PerformanceCommandCoroutineAdapter(text, line) {
companion object {
const val NAME: @NonNls String = "waitForReOpenedFile"
const val PREFIX: @NonNls String = "$CMD_PREFIX$NAME"
}
override suspend fun doExecute(context: PlaybackContext) {
val myOptions = OpenFileCommand.getOptions(extractCommandArgument(PREFIX))
val fileName = myOptions!!.file.toNioPathOrNull()!!.fileName.toString()
val connection = context.project.messageBus.connect()
var span: Span? = null
val fileOpenedLock = Mutex(true)
connection.subscribe(FileEditorManagerListener.Before.FILE_EDITOR_MANAGER, object : FileEditorManagerListener.Before {
override fun beforeFileOpened(source: FileEditorManager, file: VirtualFile) {
logger<WaitForReOpenedFileCommand>().info("beforeFileOpened ${file.name}")
if (file.name != fileName) return
span = startSpan("reopenFileAfterIdeRestart", null, "filePath" to myOptions.file)
fileOpenedLock.unlock()
}
})
fileOpenedLock.lock()
HighlightingTestUtil.waitForAnalysisWithNewApproach(context.project, span, myOptions.timeout, myOptions.suppressErrors)
connection.disconnect()
}
private fun startSpan(spanName: String, parentSpan: Span?, attribute: Pair<String, String>? = null): Span {
val builder = PerformanceTestSpan.TRACER.spanBuilder(spanName)
.setParent(if (parentSpan == null) PerformanceTestSpan.getContext() else Context.current().with(parentSpan))
if (attribute != null) builder.setAttribute(attribute.first, attribute.second)
return builder.startSpan()
}
override fun getName(): String = NAME
}
@@ -1,18 +1,10 @@
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.jetbrains.performancePlugin.utils
import com.intellij.openapi.components.service
import com.intellij.openapi.project.Project
import com.intellij.platform.diagnostic.telemetry.Scope
import com.intellij.platform.diagnostic.telemetry.TelemetryManager
import java.util.concurrent.TimeUnit
import com.intellij.openapi.util.Pair
import com.intellij.openapi.util.Ref
import com.jetbrains.performancePlugin.commands.CodeAnalysisStateListener
import io.opentelemetry.api.trace.Span
import java.util.concurrent.TimeoutException
import kotlin.time.Duration.Companion.minutes
import kotlin.time.Duration.Companion.seconds
class HighlightingTestUtil {
@@ -29,25 +21,5 @@ class HighlightingTestUtil {
span.end(System.currentTimeMillis(), TimeUnit.MILLISECONDS)
}
@JvmStatic
suspend fun waitForAnalysisWithNewApproach(project: Project, spanRef: Ref<Span>, timeout: Long, suppressErrors: Boolean) {
waitForAnalysisWithNewApproach(project, spanRef.get(), timeout, suppressErrors)
}
@JvmStatic
suspend fun waitForAnalysisWithNewApproach(project: Project, span: Span?, timeout: Long, suppressErrors: Boolean) {
val timeoutDuration = if (timeout == 0L) 5.minutes else timeout.seconds
try {
project.service<CodeAnalysisStateListener>().waitAnalysisToFinish(timeoutDuration, !suppressErrors)
}
catch (e: TimeoutException) {
span?.setAttribute("timeout", "true")
}
finally {
span?.end()
}
}
}
}