From a080ea283afc63d7536e429f8dcfff1df898a799 Mon Sep 17 00:00:00 2001 From: Anastasia Ivanova Date: Thu, 1 Apr 2021 15:50:48 +0200 Subject: [PATCH] IDEA-265654: migrate external.project.task group to StructuredIdeActivity GitOrigin-RevId: 640e70ab7ae27ce096155ec3b6b8950ac9ddff30 --- .../META-INF/ExternalSystemExtensions.xml | 2 +- .../ExternalSystemExecuteTaskTask.java | 4 +-- .../ExternalSystemResolveProjectTask.java | 6 ++-- .../statistics/ExternalSystemTaskCollector.kt | 35 +++++++++++++++++++ .../ExternalSystemUsagesCollector.kt | 27 +++++++------- 5 files changed, 54 insertions(+), 20 deletions(-) create mode 100644 platform/external-system-impl/src/com/intellij/openapi/externalSystem/statistics/ExternalSystemTaskCollector.kt diff --git a/platform/external-system-impl/resources/META-INF/ExternalSystemExtensions.xml b/platform/external-system-impl/resources/META-INF/ExternalSystemExtensions.xml index e8634543da0c..d3c53e7d6493 100644 --- a/platform/external-system-impl/resources/META-INF/ExternalSystemExtensions.xml +++ b/platform/external-system-impl/resources/META-INF/ExternalSystemExtensions.xml @@ -114,7 +114,7 @@ - + diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/internal/ExternalSystemExecuteTaskTask.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/internal/ExternalSystemExecuteTaskTask.java index fa329088126c..929c02a795d9 100644 --- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/internal/ExternalSystemExecuteTaskTask.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/internal/ExternalSystemExecuteTaskTask.java @@ -1,7 +1,7 @@ // 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.externalSystem.service.internal; -import com.intellij.internal.statistic.IdeActivity; +import com.intellij.internal.statistic.StructuredIdeActivity; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.externalSystem.model.ProjectSystemId; import com.intellij.openapi.externalSystem.model.execution.ExternalSystemTaskExecutionSettings; @@ -126,7 +126,7 @@ public class ExternalSystemExecuteTaskTask extends AbstractExternalSystemTask { throw e; } - IdeActivity activity = + StructuredIdeActivity activity = externalSystemTaskStarted(getIdeProject(), getExternalSystemId(), ExecuteTask, environmentConfigurationProvider); try { taskManager.executeTasks(id, myTasksToExecute, projectPath, settings, myJvmParametersSetup); diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/internal/ExternalSystemResolveProjectTask.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/internal/ExternalSystemResolveProjectTask.java index cb06e0a9435e..e253a7c5b48b 100644 --- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/internal/ExternalSystemResolveProjectTask.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/internal/ExternalSystemResolveProjectTask.java @@ -1,9 +1,8 @@ // 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.externalSystem.service.internal; -import com.intellij.internal.statistic.IdeActivity; +import com.intellij.internal.statistic.StructuredIdeActivity; import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.application.Experiments; import com.intellij.openapi.externalSystem.ExternalSystemManager; import com.intellij.openapi.externalSystem.importing.ImportSpec; import com.intellij.openapi.externalSystem.importing.ImportSpecImpl; @@ -110,7 +109,8 @@ public class ExternalSystemResolveProjectTask extends AbstractExternalSystemTask throw e; } - IdeActivity activity = externalSystemTaskStarted(ideProject, getExternalSystemId(), ResolveProject, environmentConfigurationProvider); + StructuredIdeActivity activity = + externalSystemTaskStarted(ideProject, getExternalSystemId(), ResolveProject, environmentConfigurationProvider); try { DataNode project = resolver.resolveProjectInfo(id, myProjectPath, myIsPreviewMode, settings, myResolverPolicy); if (project != null) { 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 new file mode 100644 index 000000000000..957a823183cb --- /dev/null +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/statistics/ExternalSystemTaskCollector.kt @@ -0,0 +1,35 @@ +// 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.execution.impl.statistics.RunConfigurationUsageTriggerCollector +import com.intellij.internal.statistic.IdeActivityGroup +import com.intellij.internal.statistic.eventLog.EventLogGroup +import com.intellij.internal.statistic.eventLog.events.EventFields +import com.intellij.internal.statistic.service.fus.collectors.CounterUsagesCollector +import com.intellij.openapi.externalSystem.statistics.ExternalSystemActionsCollector.Companion.EXTERNAL_SYSTEM_ID + +class ExternalSystemTaskCollector : CounterUsagesCollector() { + companion object { + val GROUP = EventLogGroup("external.project.task", 2) + + @JvmField + val TASK_ID_FIELD = EventFields.Enum("task_id") + + @JvmField + val TARGET_FIELD = EventFields.StringValidatedByCustomRule("target", RunConfigurationUsageTriggerCollector.RunTargetValidator.RULE_ID) + + + @JvmField + val EXTERNAL_TASK_ACTIVITY = IdeActivityGroup(GROUP, startEventAdditionalFields = arrayOf(TASK_ID_FIELD, + TARGET_FIELD, + EXTERNAL_SYSTEM_ID)) + + //@JvmField + //val INDEXING_STAGE = INDEXING_ACTIVITY.registerStage("stage", arrayOf(STAGE_CLASS)) + } + + override fun getGroup(): EventLogGroup { + return GROUP + } +} + 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 06370836f986..95931e886034 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 @@ -1,18 +1,19 @@ // Copyright 2000-2018 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.execution.impl.statistics.RunConfigurationUsageTriggerCollector -import com.intellij.internal.statistic.IdeActivity +import com.intellij.internal.statistic.StructuredIdeActivity import com.intellij.internal.statistic.beans.MetricEvent import com.intellij.internal.statistic.beans.newMetric -import com.intellij.internal.statistic.eventLog.events.EventFields -import com.intellij.internal.statistic.eventLog.events.EventFields.StringValidatedByCustomRule import com.intellij.internal.statistic.eventLog.events.EventPair import com.intellij.internal.statistic.service.fus.collectors.ProjectUsagesCollector import com.intellij.openapi.externalSystem.ExternalSystemModulePropertyManager import com.intellij.openapi.externalSystem.model.ProjectSystemId import com.intellij.openapi.externalSystem.service.execution.ExternalSystemJdkUtil import com.intellij.openapi.externalSystem.service.execution.TargetEnvironmentConfigurationProvider +import com.intellij.openapi.externalSystem.statistics.ExternalSystemActionsCollector.Companion.EXTERNAL_SYSTEM_ID +import com.intellij.openapi.externalSystem.statistics.ExternalSystemTaskCollector.Companion.EXTERNAL_TASK_ACTIVITY +import com.intellij.openapi.externalSystem.statistics.ExternalSystemTaskCollector.Companion.TARGET_FIELD +import com.intellij.openapi.externalSystem.statistics.ExternalSystemTaskCollector.Companion.TASK_ID_FIELD import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil import com.intellij.openapi.module.ModuleManager import com.intellij.openapi.project.Project @@ -24,8 +25,8 @@ class ExternalSystemUsagesCollector : ProjectUsagesCollector() { override fun getMetrics(project: Project): Set { val usages = mutableSetOf() for (manager in ExternalSystemApiUtil.getAllManagers()) { - if (!manager.getSettingsProvider().`fun`(project).getLinkedProjectsSettings().isEmpty()) { - usages.add(newMetric("externalSystemId", getAnonymizedSystemId(manager.getSystemId()))) + if (!manager.settingsProvider.`fun`(project).linkedProjectsSettings.isEmpty()) { + usages.add(newMetric("externalSystemId", getAnonymizedSystemId(manager.systemId))) } } @@ -41,9 +42,6 @@ class ExternalSystemUsagesCollector : ProjectUsagesCollector() { } companion object { - private val TASK_ID_FIELD = EventFields.Enum("task_id") - private val TARGET_FIELD = StringValidatedByCustomRule("target", RunConfigurationUsageTriggerCollector.RunTargetValidator.RULE_ID) - fun getJRETypeUsage(key: String, jreName: String?): MetricEvent { val anonymizedName = when { jreName.isNullOrBlank() -> "empty" @@ -68,13 +66,14 @@ class ExternalSystemUsagesCollector : ProjectUsagesCollector() { fun externalSystemTaskStarted(project: Project?, systemId: ProjectSystemId?, taskId: ExternalSystemTaskId, - environmentConfigurationProvider: TargetEnvironmentConfigurationProvider?): IdeActivity { - return IdeActivity(project, "external.project.task").startedWithData { data -> - addExternalSystemId(data, systemId); - EventPair(TASK_ID_FIELD, taskId).addData(data) + environmentConfigurationProvider: TargetEnvironmentConfigurationProvider?): StructuredIdeActivity { + return StructuredIdeActivity(project, EXTERNAL_TASK_ACTIVITY).started { + val data: MutableList> = mutableListOf(EXTERNAL_SYSTEM_ID.with(anonymizeSystemId(systemId))) + data.add(TASK_ID_FIELD.with(taskId)) environmentConfigurationProvider?.environmentConfiguration?.typeId?.also { - EventPair(TARGET_FIELD, it).addData(data) + data.add(TARGET_FIELD.with(it)) } + data } } }