mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-05 01:50:56 +07:00
[Observation] new: added dumping for all IDE tracked activities
GitOrigin-RevId: cab3332786669cb9face0bc91584b349c8f12f70
This commit is contained in:
committed by
intellij-monorepo-bot
parent
59dfc78696
commit
609f016002
@@ -41,13 +41,18 @@ object TestObservation {
|
||||
}
|
||||
}
|
||||
catch (_: TimeoutCancellationException) {
|
||||
val activityDump = Observation.dumpAwaitedActivitiesToString()
|
||||
val coroutineDump = dumpCoroutines()
|
||||
val threadDump = dumpThreadsToString()
|
||||
|
||||
System.err.println("""
|
||||
|The waiting takes too long. Expected to take no more than $timeout ms.
|
||||
|------ Operation log begin ------
|
||||
|$operationLog
|
||||
|------- Operation log end -------
|
||||
|------ Activity dump begin ------
|
||||
|$activityDump
|
||||
|------- Activity dump end -------
|
||||
|------- Thread dump begin -------
|
||||
|$threadDump
|
||||
|-------- Thread dump end --------
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
package com.intellij.platform.backend.observation
|
||||
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.platform.backend.observation.Observation.awaitConfiguration
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
|
||||
@@ -59,8 +60,8 @@ object Observation {
|
||||
* This method affects only those computations that use [ActivityKey], whereas [ActivityTracker] is out of reach for the platform.
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
fun getAllAwaitedActivities(): Set<Throwable> {
|
||||
return dumpCurrentlyObservedComputations()
|
||||
fun dumpAwaitedActivitiesToString(): String {
|
||||
return dumpObservedComputationsToString()
|
||||
}
|
||||
|
||||
private interface GenericActivityTracker {
|
||||
|
||||
@@ -213,10 +213,18 @@ internal class PlatformActivityTrackerService(private val scope: CoroutineScope)
|
||||
|
||||
private val computationMap : MutableMap<Job, Throwable?> = ConcurrentHashMap()
|
||||
|
||||
internal fun dumpCurrentlyObservedComputations(): Set<Throwable> {
|
||||
private fun dumpObservedComputations(): Set<Throwable> {
|
||||
return computationMap.values.mapNotNullTo(HashSet()) { it }
|
||||
}
|
||||
|
||||
internal fun dumpObservedComputationsToString(): String {
|
||||
if (!Registry.`is`("ide.activity.tracking.enable.debug")) {
|
||||
return "Enable 'ide.activity.tracking.enable.debug' registry option to collect activity traces"
|
||||
}
|
||||
return dumpObservedComputations()
|
||||
.joinToString("\n") { it.stackTraceToString() }
|
||||
}
|
||||
|
||||
internal fun traceObservedComputation(job: Job) {
|
||||
if (Registry.`is`("ide.activity.tracking.enable.debug", false)) {
|
||||
computationMap[job] = Throwable()
|
||||
|
||||
@@ -45,14 +45,10 @@ private fun CoroutineScope.launchActivityLogger(): Job {
|
||||
return launch {
|
||||
while (true) {
|
||||
delay(10.minutes)
|
||||
val currentComputations = Observation.getAllAwaitedActivities()
|
||||
buildString {
|
||||
WarmupLogger.logInfo(buildString {
|
||||
appendLine("Currently awaited activities:")
|
||||
for (trace in currentComputations) {
|
||||
appendLine(trace.stackTraceToString())
|
||||
}
|
||||
}
|
||||
WarmupLogger.logInfo(currentComputations.toString())
|
||||
appendLine(Observation.dumpAwaitedActivitiesToString())
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user