diff --git a/platform/execution-impl/src/com/intellij/execution/impl/statistics/RunConfigurationUsageTriggerCollector.java b/platform/execution-impl/src/com/intellij/execution/impl/statistics/RunConfigurationUsageTriggerCollector.java index afe78d750fd8..b0f54f5ab11d 100644 --- a/platform/execution-impl/src/com/intellij/execution/impl/statistics/RunConfigurationUsageTriggerCollector.java +++ b/platform/execution-impl/src/com/intellij/execution/impl/statistics/RunConfigurationUsageTriggerCollector.java @@ -42,7 +42,7 @@ public final class RunConfigurationUsageTriggerCollector extends CounterUsagesCo private static final EnumEventField FINISH_TYPE = EventFields.Enum("finish_type", RunConfigurationFinishType.class); - private static final IdeActivityDefinition ACTIVITY_GROUP = GROUP.registerIdeActivity( null, + private static final IdeActivityDefinition ACTIVITY_GROUP = GROUP.registerIdeActivity(null, new EventField[]{ADDITIONAL_FIELD, EXECUTOR, TARGET, RunConfigurationTypeUsagesCollector.FACTORY_FIELD, @@ -62,8 +62,8 @@ public final class RunConfigurationUsageTriggerCollector extends CounterUsagesCo @NotNull ConfigurationFactory factory, @NotNull Executor executor, @Nullable RunConfiguration runConfiguration) { - return new StructuredIdeActivity(project, ACTIVITY_GROUP) - .startedAsync(() -> ReadAction.nonBlocking(() -> buildContext(project, factory, executor, runConfiguration)) + return ACTIVITY_GROUP + .startedAsync(project, () -> ReadAction.nonBlocking(() -> buildContext(project, factory, executor, runConfiguration)) .expireWith(project) .submit(NonUrgentExecutor.getInstance())); } diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/statistics/ExternalSystemStatUtil.kt b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/statistics/ExternalSystemStatUtil.kt index 4329b32259b7..a33e36c3c501 100644 --- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/statistics/ExternalSystemStatUtil.kt +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/statistics/ExternalSystemStatUtil.kt @@ -26,7 +26,7 @@ fun anonymizeSystemId(systemId: ProjectSystemId?) = fun importActivityStarted(project: Project, externalSystemId: ProjectSystemId, dataSupplier: (() -> List>)?): StructuredIdeActivity { - return StructuredIdeActivity(project, IMPORT_ACTIVITY).started{ + return IMPORT_ACTIVITY.started(project){ val data: MutableList> = mutableListOf(EXTERNAL_SYSTEM_ID.with(anonymizeSystemId(externalSystemId))) if(dataSupplier != null) { data.addAll(dataSupplier()) diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/statistics/ExternalSystemTaskCollector.kt b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/statistics/ExternalSystemTaskCollector.kt index 58ff1bdca60a..986b507be88b 100644 --- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/statistics/ExternalSystemTaskCollector.kt +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/statistics/ExternalSystemTaskCollector.kt @@ -2,7 +2,6 @@ package com.intellij.openapi.externalSystem.statistics import com.intellij.execution.impl.statistics.RunConfigurationUsageTriggerCollector -import com.intellij.internal.statistic.IdeActivityDefinition import com.intellij.internal.statistic.eventLog.EventLogGroup import com.intellij.internal.statistic.eventLog.events.EventFields import com.intellij.internal.statistic.service.fus.collectors.CounterUsagesCollector @@ -21,8 +20,8 @@ class ExternalSystemTaskCollector : CounterUsagesCollector() { @JvmField val EXTERNAL_TASK_ACTIVITY = GROUP.registerIdeActivity(null, startEventAdditionalFields = arrayOf(TASK_ID_FIELD, - TARGET_FIELD, - EXTERNAL_SYSTEM_ID)) + TARGET_FIELD, + EXTERNAL_SYSTEM_ID)) } override fun getGroup(): EventLogGroup { diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/statistics/ExternalSystemUsagesCollector.kt b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/statistics/ExternalSystemUsagesCollector.kt index 95931e886034..042ace0fbbea 100644 --- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/statistics/ExternalSystemUsagesCollector.kt +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/statistics/ExternalSystemUsagesCollector.kt @@ -67,7 +67,7 @@ class ExternalSystemUsagesCollector : ProjectUsagesCollector() { systemId: ProjectSystemId?, taskId: ExternalSystemTaskId, environmentConfigurationProvider: TargetEnvironmentConfigurationProvider?): StructuredIdeActivity { - return StructuredIdeActivity(project, EXTERNAL_TASK_ACTIVITY).started { + return EXTERNAL_TASK_ACTIVITY.started(project) { val data: MutableList> = mutableListOf(EXTERNAL_SYSTEM_ID.with(anonymizeSystemId(systemId))) data.add(TASK_ID_FIELD.with(taskId)) environmentConfigurationProvider?.environmentConfiguration?.typeId?.also { diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/statistics/ProjectImportCollector.kt b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/statistics/ProjectImportCollector.kt index e235291ab57b..b46237914d64 100644 --- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/statistics/ProjectImportCollector.kt +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/statistics/ProjectImportCollector.kt @@ -1,7 +1,6 @@ // Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.openapi.externalSystem.statistics -import com.intellij.internal.statistic.IdeActivityDefinition import com.intellij.internal.statistic.eventLog.EventLogGroup import com.intellij.internal.statistic.eventLog.events.EventFields import com.intellij.internal.statistic.service.fus.collectors.CounterUsagesCollector @@ -15,7 +14,8 @@ class ProjectImportCollector : CounterUsagesCollector() { val TASK_CLASS = EventFields.Class("task_class") @JvmField - val IMPORT_ACTIVITY = GROUP.registerIdeActivity( null, startEventAdditionalFields=arrayOf(EXTERNAL_SYSTEM_ID, TASK_CLASS, EventFields.PluginInfo)) + val IMPORT_ACTIVITY = GROUP.registerIdeActivity(null, startEventAdditionalFields = arrayOf(EXTERNAL_SYSTEM_ID, TASK_CLASS, + EventFields.PluginInfo)) } override fun getGroup(): EventLogGroup { diff --git a/platform/lang-impl/src/com/intellij/task/impl/ProjectTaskManagerImpl.java b/platform/lang-impl/src/com/intellij/task/impl/ProjectTaskManagerImpl.java index 01580d070078..720f539dbf28 100644 --- a/platform/lang-impl/src/com/intellij/task/impl/ProjectTaskManagerImpl.java +++ b/platform/lang-impl/src/com/intellij/task/impl/ProjectTaskManagerImpl.java @@ -181,7 +181,7 @@ public final class ProjectTaskManagerImpl extends ProjectTaskManager { }); - StructuredIdeActivity activity = new StructuredIdeActivity(myProject, BUILD_ACTIVITY).started(() -> + StructuredIdeActivity activity = BUILD_ACTIVITY.started(myProject, () -> Collections.singletonList(TASK_RUNNER.with(map(toRun, it -> it.first.getClass().getName()))) ); diff --git a/platform/lang-impl/src/com/intellij/task/impl/ProjectTaskManagerStatisticsCollector.kt b/platform/lang-impl/src/com/intellij/task/impl/ProjectTaskManagerStatisticsCollector.kt index ac762fed874e..64b1299c4f3c 100644 --- a/platform/lang-impl/src/com/intellij/task/impl/ProjectTaskManagerStatisticsCollector.kt +++ b/platform/lang-impl/src/com/intellij/task/impl/ProjectTaskManagerStatisticsCollector.kt @@ -1,7 +1,6 @@ // Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.task.impl -import com.intellij.internal.statistic.IdeActivityDefinition import com.intellij.internal.statistic.eventLog.EventLogGroup import com.intellij.internal.statistic.eventLog.events.EventFields import com.intellij.internal.statistic.service.fus.collectors.CounterUsagesCollector @@ -11,10 +10,10 @@ class ProjectTaskManagerStatisticsCollector : CounterUsagesCollector() { val GROUP = EventLogGroup("build", 4) @JvmField - val TASK_RUNNER = EventFields.StringListValidatedByCustomRule("task_runner_class","class_name") + val TASK_RUNNER = EventFields.StringListValidatedByCustomRule("task_runner_class", "class_name") @JvmField - val BUILD_ACTIVITY = GROUP.registerIdeActivity( null, startEventAdditionalFields = arrayOf(TASK_RUNNER, EventFields.PluginInfo)) + val BUILD_ACTIVITY = GROUP.registerIdeActivity(null, startEventAdditionalFields = arrayOf(TASK_RUNNER, EventFields.PluginInfo)) } override fun getGroup(): EventLogGroup { diff --git a/platform/platform-impl/src/com/intellij/openapi/project/DumbServiceImpl.java b/platform/platform-impl/src/com/intellij/openapi/project/DumbServiceImpl.java index ba196ae80fa7..28147b8fe6c9 100644 --- a/platform/platform-impl/src/com/intellij/openapi/project/DumbServiceImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/project/DumbServiceImpl.java @@ -606,7 +606,7 @@ public class DumbServiceImpl extends DumbService implements Disposable, Modifica try (ProgressSuspender suspender = ProgressSuspender.markSuspendable(visibleIndicator, IdeBundle.message("progress.text.indexing.paused"))) { myHeavyActivities.setCurrentSuspenderAndSuspendIfRequested(suspender); - StructuredIdeActivity activity = new StructuredIdeActivity(myProject, IndexingStatisticsCollector.INDEXING_ACTIVITY).started(); + StructuredIdeActivity activity = IndexingStatisticsCollector.INDEXING_ACTIVITY.started(myProject); final ShutDownTracker shutdownTracker = ShutDownTracker.getInstance(); final Thread self = Thread.currentThread(); diff --git a/platform/platform-impl/src/com/intellij/openapi/project/IndexingStatisticsCollector.kt b/platform/platform-impl/src/com/intellij/openapi/project/IndexingStatisticsCollector.kt index 64e2cb82d377..5a9d0abdecbf 100644 --- a/platform/platform-impl/src/com/intellij/openapi/project/IndexingStatisticsCollector.kt +++ b/platform/platform-impl/src/com/intellij/openapi/project/IndexingStatisticsCollector.kt @@ -1,7 +1,6 @@ // Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.openapi.project -import com.intellij.internal.statistic.IdeActivityDefinition import com.intellij.internal.statistic.eventLog.EventLogGroup import com.intellij.internal.statistic.eventLog.events.EventFields import com.intellij.internal.statistic.service.fus.collectors.CounterUsagesCollector @@ -14,7 +13,7 @@ class IndexingStatisticsCollector : CounterUsagesCollector() { val STAGE_CLASS = EventFields.Class("stage_class") @JvmField - val INDEXING_ACTIVITY = GROUP.registerIdeActivity( null, startEventAdditionalFields = arrayOf(EventFields.PluginInfo)) + val INDEXING_ACTIVITY = GROUP.registerIdeActivity(null, startEventAdditionalFields = arrayOf(EventFields.PluginInfo)) @JvmField val INDEXING_STAGE = INDEXING_ACTIVITY.registerStage("stage", arrayOf(STAGE_CLASS)) diff --git a/platform/statistics/src/com/intellij/internal/statistic/StructuredIdeActivity.kt b/platform/statistics/src/com/intellij/internal/statistic/StructuredIdeActivity.kt index 99e9df7845cc..fb3aba050f43 100644 --- a/platform/statistics/src/com/intellij/internal/statistic/StructuredIdeActivity.kt +++ b/platform/statistics/src/com/intellij/internal/statistic/StructuredIdeActivity.kt @@ -16,8 +16,8 @@ import java.util.concurrent.atomic.AtomicInteger private val LOG = Logger.getInstance(StructuredIdeActivity::class.java) @ApiStatus.Internal -class StructuredIdeActivity constructor(private val projectOrNullForApplication: Project?, - private val ideActivityDefinition: IdeActivityDefinition) { +class StructuredIdeActivity internal constructor(private val projectOrNullForApplication: Project?, + private val ideActivityDefinition: IdeActivityDefinition) { private val id = counter.incrementAndGet() private var state = IdeActivityState.NOT_STARTED @@ -86,14 +86,23 @@ class StructuredIdeActivity constructor(private val projectOrNullForApplication: } } -class IdeActivityDefinition constructor(val group: EventLogGroup, - val activityName: String?, - startEventAdditionalFields: Array> = emptyArray(), - finishEventAdditionalFields: Array> = emptyArray()) { +class IdeActivityDefinition internal constructor(val group: EventLogGroup, + val activityName: String?, + startEventAdditionalFields: Array> = emptyArray(), + finishEventAdditionalFields: Array> = emptyArray()) { val started = group.registerVarargEvent(appendActivityName(activityName, "started"), activityId, *startEventAdditionalFields) val finished = group.registerVarargEvent(appendActivityName(activityName, "finished"), activityId, EventFields.DurationMs, *finishEventAdditionalFields) + @JvmOverloads + fun started(project: Project?, dataSupplier: (() -> List>)? = null): StructuredIdeActivity { + return StructuredIdeActivity(project, this).started(dataSupplier) + } + + fun startedAsync(project: Project?, dataSupplier: () -> Promise>>): StructuredIdeActivity { + return StructuredIdeActivity(project, this).startedAsync(dataSupplier) + } + private fun appendActivityName(activityName: String?, state: String): String { if (activityName == null) return state return "$activityName.$state" diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/VcsStatisticsCollector.kt b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/VcsStatisticsCollector.kt index 3f4117d8609f..737f9f30e98d 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/VcsStatisticsCollector.kt +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/VcsStatisticsCollector.kt @@ -1,7 +1,6 @@ // Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.openapi.vcs.changes.actions -import com.intellij.internal.statistic.IdeActivityDefinition import com.intellij.internal.statistic.eventLog.EventLogGroup import com.intellij.internal.statistic.eventLog.events.EventFields import com.intellij.internal.statistic.service.fus.collectors.CounterUsagesCollector @@ -26,7 +25,8 @@ class VcsStatisticsCollector : CounterUsagesCollector() { private val WAS_UPDATING_BEFORE = EventFields.Boolean("wasUpdatingBefore") private val CHANGES_DELTA = EventFields.Int("changesDelta") private val UNVERSIONED_DELTA = EventFields.Int("unversionedDelta") - private val CHANGES_VIEW_REFRESH = GROUP.registerVarargEvent("changes.view.refresh", WAS_UPDATING_BEFORE, CHANGES_DELTA, UNVERSIONED_DELTA) + private val CHANGES_VIEW_REFRESH = GROUP.registerVarargEvent("changes.view.refresh", WAS_UPDATING_BEFORE, CHANGES_DELTA, + UNVERSIONED_DELTA) val NON_MODAL_COMMIT_STATE_CHANGED = GROUP.registerEvent("non.modal.commit.state.changed", EventFields.Enabled) val NON_MODAL_COMMIT_PROMOTION_SHOWN = GROUP.registerEvent("non.modal.commit.promotion.shown") diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/update/AbstractCommonUpdateAction.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/update/AbstractCommonUpdateAction.java index 8b00a82b683d..63958762411c 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/update/AbstractCommonUpdateAction.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/update/AbstractCommonUpdateAction.java @@ -334,7 +334,7 @@ public abstract class AbstractCommonUpdateAction extends AbstractVcsAction imple if (progressIndicator != null) { progressIndicator.setIndeterminate(false); } - StructuredIdeActivity activity = new StructuredIdeActivity(myProject, UPDATE_ACTIVITY).started(); + StructuredIdeActivity activity = UPDATE_ACTIVITY.started(myProject); try { int toBeProcessed = myVcsToVirtualFiles.size(); int processed = 0; diff --git a/platform/vcs-impl/src/com/intellij/vcs/commit/AbstractCommitter.kt b/platform/vcs-impl/src/com/intellij/vcs/commit/AbstractCommitter.kt index 83fa1bc52274..f18bfcbdc793 100644 --- a/platform/vcs-impl/src/com/intellij/vcs/commit/AbstractCommitter.kt +++ b/platform/vcs-impl/src/com/intellij/vcs/commit/AbstractCommitter.kt @@ -2,7 +2,6 @@ package com.intellij.vcs.commit import com.intellij.ide.util.DelegatingProgressIndicator -import com.intellij.internal.statistic.StructuredIdeActivity import com.intellij.openapi.application.TransactionGuard import com.intellij.openapi.diagnostic.logger import com.intellij.openapi.progress.ProcessCanceledException @@ -50,7 +49,7 @@ abstract class AbstractCommitter( val task = object : Task.Backgroundable(project, taskName, true, configuration.commitOption) { override fun run(indicator: ProgressIndicator) { val vcsManager = ProjectLevelVcsManager.getInstance(project) - val activity = StructuredIdeActivity(myProject, COMMIT_ACTIVITY).started() // NON-NLS + val activity = COMMIT_ACTIVITY.started(myProject) // NON-NLS vcsManager.startBackgroundVcsOperation() try { delegateCommitToVcsThread() diff --git a/plugins/git4idea/src/git4idea/fetch/GitFetchSupportImpl.kt b/plugins/git4idea/src/git4idea/fetch/GitFetchSupportImpl.kt index dfbd9d8cdf42..75c2602226e7 100644 --- a/plugins/git4idea/src/git4idea/fetch/GitFetchSupportImpl.kt +++ b/plugins/git4idea/src/git4idea/fetch/GitFetchSupportImpl.kt @@ -3,7 +3,6 @@ package git4idea.fetch import com.intellij.dvcs.MultiMessage import com.intellij.dvcs.MultiRootMessage -import com.intellij.internal.statistic.StructuredIdeActivity import com.intellij.notification.NotificationType import com.intellij.openapi.diagnostic.logger import com.intellij.openapi.progress.EmptyProgressIndicator @@ -100,7 +99,7 @@ internal class GitFetchSupportImpl(private val project: Project) : GitFetchSuppo try { fetchRequestCounter.incrementAndGet() return withIndicator { - val activity = StructuredIdeActivity(project, VcsStatisticsCollector.FETCH_ACTIVITY).started() + val activity = VcsStatisticsCollector.FETCH_ACTIVITY.started(project) val tasks = fetchInParallel(arguments) val results = waitForFetchTasks(tasks)