mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-15 02:59:33 +07:00
AT-3148 Get rid of Progress Indicators reports to the Diogen since it create 1 mio reports per month
(cherry picked from commit bd76c42dc3d62ee56d83668ad5f37a228a7fee4e) IJ-CR-175658 GitOrigin-RevId: 9bc0f96244e28c9646b068d8cadc0ef62a259d5f
This commit is contained in:
committed by
intellij-monorepo-bot
parent
36198c99a0
commit
139f30fe69
@@ -248,7 +248,6 @@ class InfoAndProgressPanel internal constructor(private val statusBar: IdeStatus
|
||||
infos.add(info)
|
||||
val expanded = createInlineDelegate(info = info, original = original, compact = false)
|
||||
val compact = createInlineDelegate(info = info, original = original, compact = true)
|
||||
IntegrationTestsProgressesTracker.progressStarted(original)
|
||||
getPopup().addIndicator(expanded)
|
||||
balloon.addIndicator(rootPane, compact)
|
||||
updateProgressIcon()
|
||||
@@ -261,7 +260,6 @@ class InfoAndProgressPanel internal constructor(private val statusBar: IdeStatus
|
||||
// already finished, progress might not send another finished message
|
||||
removeProgress(expanded)
|
||||
removeProgress(compact)
|
||||
IntegrationTestsProgressesTracker.progressStopped(original)
|
||||
return
|
||||
}
|
||||
coroutineScope.launch {
|
||||
@@ -293,7 +291,6 @@ class InfoAndProgressPanel internal constructor(private val statusBar: IdeStatus
|
||||
return
|
||||
}
|
||||
mainPanel.removeProgress(progress, last)
|
||||
IntegrationTestsProgressesTracker.progressStopped(original)
|
||||
coroutineScope.launch {
|
||||
runQuery()
|
||||
}
|
||||
|
||||
@@ -1,77 +0,0 @@
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.openapi.wm.impl.status
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.application.ex.ApplicationManagerEx
|
||||
import com.intellij.openapi.progress.ProgressModel
|
||||
import com.intellij.openapi.util.text.StringUtil
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
import java.util.concurrent.Future
|
||||
|
||||
internal object IntegrationTestsProgressesTracker {
|
||||
private val enabled = ApplicationManagerEx.isInIntegrationTest() && System.getProperty("idea.performanceReport.projectName") != null
|
||||
private val lock = Object()
|
||||
private val timestamps: MutableMap<ProgressModel, Long> = ConcurrentHashMap<ProgressModel, Long>()
|
||||
|
||||
// See com.intellij.openapi.wm.impl.status.ProgressComponent.updateProgressNow
|
||||
private fun getTitle(indicatorModel: ProgressModel): String {
|
||||
val text = indicatorModel.getText()
|
||||
return if (!StringUtil.isEmpty(text)) text!! else indicatorModel.title
|
||||
}
|
||||
|
||||
fun progressStarted(indicatorModel: ProgressModel) {
|
||||
if (!enabled) return
|
||||
synchronized(lock) {
|
||||
timestamps[indicatorModel] = System.currentTimeMillis()
|
||||
}
|
||||
}
|
||||
|
||||
fun progressTitleChanged(indicatorModel: ProgressModel, oldTextValue: String, newTextValue: String) {
|
||||
if (!enabled) return
|
||||
if (oldTextValue == newTextValue) return
|
||||
synchronized(lock) {
|
||||
val now = System.currentTimeMillis()
|
||||
val was = timestamps.replace(indicatorModel, now)
|
||||
if (isUnnoticeableUnnamedProgress(oldTextValue, was, now)) return
|
||||
val message = createMessage(was, now, oldTextValue, indicatorModel.visibleInStatusBar, "changed message")
|
||||
sendMessage(message)
|
||||
}
|
||||
}
|
||||
|
||||
private fun createMessage(was: Long?, now: Long, text: String, visibleInStatusBar: Boolean, action: String): String {
|
||||
val longer = when {
|
||||
was == null -> "unknown"
|
||||
was + 3000 < now -> "true"
|
||||
else -> "false"
|
||||
}
|
||||
val timeInMillis = if (was == null) "?" else (now - was).toString()
|
||||
return "Progress Indicator Test Stats:\n" +
|
||||
"v2\n" +
|
||||
(if (visibleInStatusBar) "Primary" else "Secondary") + "\n" +
|
||||
"$action\n" +
|
||||
"longer than 3 seconds: $longer\n" +
|
||||
"time: $timeInMillis ms\n" +
|
||||
"message: " + text.ifBlank { "<empty>" }
|
||||
}
|
||||
|
||||
private fun isUnnoticeableUnnamedProgress(text: String, was: Long?, now: Long): Boolean {
|
||||
return text.isBlank() && was != null && (now - was < 200)
|
||||
}
|
||||
|
||||
fun progressStopped(indicatorModel: ProgressModel?) {
|
||||
if (!enabled) return
|
||||
if (indicatorModel == null) return
|
||||
synchronized(lock) {
|
||||
val now = System.currentTimeMillis()
|
||||
val was = timestamps.remove(indicatorModel)
|
||||
val title = getTitle(indicatorModel)
|
||||
if (isUnnoticeableUnnamedProgress(title, was, now)) return
|
||||
sendMessage(createMessage(was, now, title, indicatorModel.visibleInStatusBar, "stopped"))
|
||||
}
|
||||
}
|
||||
|
||||
private fun sendMessage(message: String): Future<*> = ApplicationManager.getApplication().executeOnPooledThread {
|
||||
throw RuntimeException(message)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -183,7 +183,6 @@ open class ProgressComponent(val isCompact: Boolean, val info: TaskInfo, progres
|
||||
progress.setValue((fraction * 99 + 1).toInt())
|
||||
}
|
||||
|
||||
val oldTextValue = this.textValue
|
||||
val text = indicatorModel.getText()
|
||||
val text2 = indicatorModel.getDetails()
|
||||
this.textValue = text ?: ""
|
||||
@@ -193,8 +192,6 @@ open class ProgressComponent(val isCompact: Boolean, val info: TaskInfo, progres
|
||||
this.textValue = indicatorModel.title
|
||||
}
|
||||
|
||||
IntegrationTestsProgressesTracker.progressTitleChanged(indicatorModel, oldTextValue?: "", this.textValue?: "")
|
||||
|
||||
if (this.isStopping) {
|
||||
if (isCompact) {
|
||||
this.textValue = IdeBundle.message("progress.text.stopping", this.textValue)
|
||||
|
||||
Reference in New Issue
Block a user