IDEA-265399 - added statistic collector to receive information about entry points usages, complemented info about inspection profiles amount

GitOrigin-RevId: bc2e4911f055904f1e6a4bfce2c581d4cc4e61d6
This commit is contained in:
Ilyas Selimov
2021-04-09 04:25:53 +00:00
committed by intellij-monorepo-bot
parent 744d868589
commit 62ee5d216b
4 changed files with 59 additions and 3 deletions
@@ -543,6 +543,10 @@ public abstract class EntryPointsManagerBase extends EntryPointsManager implemen
return false;
}
public List<String> getWriteAnnotations() {
return List.copyOf(myWriteAnnotations);
}
public LinkedHashSet<ClassPattern> getPatterns() {
return myPatterns;
}
@@ -433,6 +433,7 @@
<statistics.counterUsagesCollector implementationClass="com.intellij.debugger.actions.JavaDebuggerActionsCollector"/>
<statistics.applicationUsagesCollector implementation="com.intellij.debugger.settings.DebuggerSettingsStatisticsCollector"/>
<statistics.applicationUsagesCollector implementation="com.intellij.refactoring.JavaRefactoringUsageCollector"/>
<statistics.projectUsagesCollector implementation="com.intellij.codeInspection.deadCode.EntryPointsUsageCollector"/>
<applicationService serviceInterface="com.intellij.packaging.elements.PackagingElementFactory"
serviceImplementation="com.intellij.packaging.impl.elements.PackagingElementFactoryImpl"/>
@@ -0,0 +1,44 @@
// 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.codeInspection.deadCode;
import com.intellij.codeInspection.ex.EntryPointsManagerBase;
import com.intellij.internal.statistic.beans.MetricEvent;
import com.intellij.internal.statistic.eventLog.EventLogGroup;
import com.intellij.internal.statistic.eventLog.events.EventFields;
import com.intellij.internal.statistic.eventLog.events.EventId1;
import com.intellij.internal.statistic.eventLog.events.EventId2;
import com.intellij.internal.statistic.service.fus.collectors.ProjectUsagesCollector;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.NotNull;
import java.util.LinkedHashSet;
import java.util.Set;
public class EntryPointsUsageCollector extends ProjectUsagesCollector {
private static final EventLogGroup GROUP = new EventLogGroup("entry.points", 1);
private static final EventId2<Boolean, Boolean> ANNOTATIONS =
GROUP.registerEvent("annotations",
EventFields.Boolean("additional_used"),
EventFields.Boolean("write_used"));
private static final EventId1<Boolean> PATTERNS =
GROUP.registerEvent("patterns",
EventFields.Boolean("used"));
@Override
public EventLogGroup getGroup() {
return GROUP;
}
@Override
protected @NotNull Set<MetricEvent> getMetrics(@NotNull Project project) {
EntryPointsManagerBase entryPointManager = EntryPointsManagerBase.getInstance(project);
boolean additionalAnnotationsUsed = !entryPointManager.getAdditionalAnnotations().isEmpty();
boolean writeAnnotationsUsed = !entryPointManager.getWriteAnnotations().isEmpty();
boolean patternsUsed = !entryPointManager.getPatterns().isEmpty();
Set<MetricEvent> result = new LinkedHashSet<>();
result.add(ANNOTATIONS.metric(additionalAnnotationsUsed, writeAnnotationsUsed));
result.add(PATTERNS.metric(patternsUsed));
return result;
}
}
@@ -10,7 +10,9 @@ import com.intellij.internal.statistic.beans.MetricEvent;
import com.intellij.internal.statistic.beans.MetricEventFactoryKt;
import com.intellij.internal.statistic.eventLog.EventLogGroup;
import com.intellij.internal.statistic.eventLog.FeatureUsageData;
import com.intellij.internal.statistic.eventLog.events.*;
import com.intellij.internal.statistic.eventLog.events.EventFields;
import com.intellij.internal.statistic.eventLog.events.EventId1;
import com.intellij.internal.statistic.eventLog.events.EventId3;
import com.intellij.internal.statistic.eventLog.validator.ValidationResultType;
import com.intellij.internal.statistic.eventLog.validator.rules.EventContext;
import com.intellij.internal.statistic.eventLog.validator.rules.impl.CustomValidationRule;
@@ -44,7 +46,10 @@ public class InspectionsUsagesCollector extends ProjectUsagesCollector {
private static final String OPTION_NAME = "option_name";
private static final String INSPECTION_ID = "inspection_id";
private static final EventLogGroup GROUP = new EventLogGroup("inspections", 5);
private static final EventLogGroup GROUP = new EventLogGroup("inspections", 6);
private static final EventId1<Integer> PROFILES =
GROUP.registerEvent("profiles",
EventFields.Int("amount"));
private static final EventId3<Boolean, Boolean, Boolean> PROFILE =
GROUP.registerEvent("used.profile",
EventFields.Boolean("project_level"),
@@ -61,7 +66,9 @@ public class InspectionsUsagesCollector extends ProjectUsagesCollector {
public Set<MetricEvent> getMetrics(@NotNull final Project project) {
final Set<MetricEvent> result = new HashSet<>();
final var profile = InspectionProjectProfileManager.getInstance(project).getCurrentProfile();
final var profileManager = InspectionProjectProfileManager.getInstance(project);
result.add(PROFILES.metric(profileManager.getProfiles().size()));
final var profile = profileManager.getCurrentProfile();
result.add(create(profile));
final List<ScopeToolState> tools = profile.getAllTools();