mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-345401 Report cancelled health checks
GitOrigin-RevId: 2380fa4f35433f12b3a7186f4a02654b48949c52
This commit is contained in:
committed by
intellij-monorepo-bot
parent
56bf3f8534
commit
9606d15f40
+26
-2
@@ -11,7 +11,7 @@ import com.intellij.openapi.project.Project
|
||||
*/
|
||||
internal object IndexableFilesFilterHealthCheckCollector : CounterUsagesCollector() {
|
||||
private val GROUP = EventLogGroup("indexable.files.filter",
|
||||
7,
|
||||
8,
|
||||
"FUS",
|
||||
"Collects statistics of ProjectIndexableFilesFilterHealthCheck. " +
|
||||
"See more here: https://youtrack.jetbrains.com/articles/IJPL-A-300/indexable.files.filter")
|
||||
@@ -22,6 +22,7 @@ internal object IndexableFilesFilterHealthCheckCollector : CounterUsagesCollecto
|
||||
private val attemptNumberInProjectField = EventFields.Int("attempt_number_in_project", "Health check attempt number in a given project. First is 1.")
|
||||
private val successfulAttemptNumberInProjectField = EventFields.Int("successful_attempt_number_in_project", "Finished (not-cancelled) health check attempt number in a given project. First is 1.")
|
||||
private val durationMsFiled = EventFields.Int("duration_ms", "Health check duration in milliseconds")
|
||||
private val cancelledAttemptNumberInProjectField = EventFields.Int("cancelled_attempt_number_in_project", "Cancelled health check attempt number in a given project. First is 1.")
|
||||
private val nonIndexableFilesInFilterField = EventFields.Int("non_indexable_files_in_filter_count")
|
||||
private val indexableFilesNotInFilterField = EventFields.Int("indexable_files_not_in_filter_count")
|
||||
|
||||
@@ -40,7 +41,16 @@ internal object IndexableFilesFilterHealthCheckCollector : CounterUsagesCollecto
|
||||
"indexable_files_filter_health_check_started",
|
||||
filterNameField,
|
||||
attemptNumberInProjectField,
|
||||
description = "Even which happens every time health check is started."
|
||||
description = "Event which happens every time health check is started."
|
||||
)
|
||||
|
||||
private val indexableFilesFilterHealthCheckCancelled = GROUP.registerVarargEvent(
|
||||
"indexable_files_filter_health_check_cancelled",
|
||||
description = "Event which happens every time health check is cancelled e.g. because scanning was in progress.",
|
||||
filterNameField,
|
||||
attemptNumberInProjectField,
|
||||
cancelledAttemptNumberInProjectField,
|
||||
durationMsFiled,
|
||||
)
|
||||
|
||||
fun reportIndexableFilesFilterHealthcheckStarted(project: Project,
|
||||
@@ -72,6 +82,20 @@ internal object IndexableFilesFilterHealthCheckCollector : CounterUsagesCollecto
|
||||
)
|
||||
}
|
||||
|
||||
fun reportIndexableFilesFilterHealthcheckCancelled(project: Project,
|
||||
filter: ProjectIndexableFilesFilter,
|
||||
attemptNumber: Int,
|
||||
cancelledAttemptNumber: Int,
|
||||
durationMs: Int) {
|
||||
indexableFilesFilterHealthCheckCancelled.log(
|
||||
project,
|
||||
filterNameField.with(getFilterName(filter)),
|
||||
attemptNumberInProjectField.with(attemptNumber),
|
||||
cancelledAttemptNumberInProjectField.with(cancelledAttemptNumber),
|
||||
durationMsFiled.with(durationMs),
|
||||
)
|
||||
}
|
||||
|
||||
private fun getFilterName(filter: ProjectIndexableFilesFilter): String? {
|
||||
return when (filter) {
|
||||
is CachingProjectIndexableFilesFilter -> "caching"
|
||||
|
||||
+13
-2
@@ -59,6 +59,7 @@ private class ProjectIndexableFilesFilterHealthCheckStarter : ProjectActivity {
|
||||
class ProjectIndexableFilesFilterHealthCheck(private val project: Project, private val coroutineScope: CoroutineScope) {
|
||||
private val isRunning = AtomicBoolean()
|
||||
private val attemptsCount = AtomicInteger()
|
||||
private val cancelledAttemptsCount = AtomicInteger()
|
||||
private val successfulAttemptsCount = AtomicInteger()
|
||||
|
||||
fun launchHealthCheck() {
|
||||
@@ -99,9 +100,19 @@ class ProjectIndexableFilesFilterHealthCheck(private val project: Project, priva
|
||||
val startTime = System.currentTimeMillis()
|
||||
|
||||
Observation.awaitConfiguration(project) // wait for project import IDEA-348501
|
||||
val (nonIndexableFilesInFilter, indexableFilesNotInFilter) = smartReadAction(project) {
|
||||
val res = smartReadAction(project) {
|
||||
runHealthCheck(project, filter)
|
||||
} ?: return
|
||||
}
|
||||
if (res == null) {
|
||||
IndexableFilesFilterHealthCheckCollector.reportIndexableFilesFilterHealthcheckCancelled(
|
||||
project,
|
||||
filter,
|
||||
attemptNumber,
|
||||
cancelledAttemptsCount.incrementAndGet(),
|
||||
(System.currentTimeMillis() - startTime).toInt())
|
||||
return
|
||||
}
|
||||
val (nonIndexableFilesInFilter, indexableFilesNotInFilter) = res
|
||||
|
||||
nonIndexableFilesInFilter.fix(filter)
|
||||
indexableFilesNotInFilter.fix(filter)
|
||||
|
||||
Reference in New Issue
Block a user