mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
FUS: check that state collector is implemented in JB plugin
GitOrigin-RevId: 886bc8b76db314d9f675d4ea0c4a7183724b0c3c
This commit is contained in:
committed by
intellij-monorepo-bot
parent
b156699911
commit
58c5f63600
+29
-24
@@ -6,6 +6,8 @@ import com.intellij.internal.statistic.eventLog.EventLogGroup;
|
||||
import com.intellij.internal.statistic.eventLog.EventLogSystemEvents;
|
||||
import com.intellij.internal.statistic.eventLog.FeatureUsageData;
|
||||
import com.intellij.internal.statistic.eventLog.fus.FeatureUsageLogger;
|
||||
import com.intellij.internal.statistic.utils.PluginInfo;
|
||||
import com.intellij.internal.statistic.utils.PluginInfoDetectorKt;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -33,13 +35,11 @@ public class FUStateUsagesLogger implements UsagesCollectorConsumer {
|
||||
synchronized (LOCK) {
|
||||
List<CompletableFuture<Void>> futures = new ArrayList<>();
|
||||
for (ProjectUsagesCollector usagesCollector : ProjectUsagesCollector.getExtensions(this)) {
|
||||
final EventLogGroup group = new EventLogGroup(usagesCollector.getGroupId(), usagesCollector.getVersion());
|
||||
try {
|
||||
futures.add(logUsagesAsStateEvents(project, group, usagesCollector.getData(project),
|
||||
usagesCollector.getMetrics(project, indicator)));
|
||||
}
|
||||
catch (Throwable th) {
|
||||
futures.add(logCollectingUsageFailed(project, group, th));
|
||||
PluginInfo info = PluginInfoDetectorKt.getPluginInfo(usagesCollector.getClass());
|
||||
if (info.isDevelopedByJetBrains()) {
|
||||
EventLogGroup group = new EventLogGroup(usagesCollector.getGroupId(), usagesCollector.getVersion());
|
||||
Promise<? extends Set<MetricEvent>> metrics = usagesCollector.getMetrics(project, indicator);
|
||||
futures.add(logMetricsOrError(project, group, usagesCollector.getData(project), metrics));
|
||||
}
|
||||
}
|
||||
return CompletableFuture.allOf(futures.toArray(new CompletableFuture[0]));
|
||||
@@ -50,19 +50,34 @@ public class FUStateUsagesLogger implements UsagesCollectorConsumer {
|
||||
synchronized (LOCK) {
|
||||
List<CompletableFuture<Void>> futures = new ArrayList<>();
|
||||
for (ApplicationUsagesCollector usagesCollector : ApplicationUsagesCollector.getExtensions(this)) {
|
||||
final EventLogGroup group = new EventLogGroup(usagesCollector.getGroupId(), usagesCollector.getVersion());
|
||||
try {
|
||||
futures.add(logUsagesAsStateEvents(null, group, usagesCollector.getData(),
|
||||
Promises.resolvedPromise(usagesCollector.getMetrics())));
|
||||
}
|
||||
catch (Throwable th) {
|
||||
futures.add(logCollectingUsageFailed(null, group, th));
|
||||
PluginInfo info = PluginInfoDetectorKt.getPluginInfo(usagesCollector.getClass());
|
||||
if (info.isDevelopedByJetBrains()) {
|
||||
EventLogGroup group = new EventLogGroup(usagesCollector.getGroupId(), usagesCollector.getVersion());
|
||||
Promise<Set<MetricEvent>> metrics = Promises.resolvedPromise(usagesCollector.getMetrics());
|
||||
futures.add(logMetricsOrError(null, group, usagesCollector.getData(), metrics));
|
||||
}
|
||||
}
|
||||
return CompletableFuture.allOf(futures.toArray(new CompletableFuture[0]));
|
||||
}
|
||||
}
|
||||
|
||||
private static CompletableFuture<Void> logMetricsOrError(@Nullable Project project,
|
||||
@NotNull EventLogGroup group,
|
||||
@Nullable FeatureUsageData context,
|
||||
@NotNull Promise<? extends Set<MetricEvent>> metricsPromise) {
|
||||
try {
|
||||
return logUsagesAsStateEvents(project, group, context, metricsPromise);
|
||||
}
|
||||
catch (Throwable th) {
|
||||
if (project != null && project.isDisposed()) {
|
||||
return CompletableFuture.completedFuture(null);
|
||||
}
|
||||
|
||||
FeatureUsageData data = new FeatureUsageData().addProject(project);
|
||||
return FeatureUsageLogger.INSTANCE.logState(group, EventLogSystemEvents.STATE_COLLECTOR_FAILED, data.build());
|
||||
}
|
||||
}
|
||||
|
||||
private static @NotNull CompletableFuture<Void> logUsagesAsStateEvents(@Nullable Project project,
|
||||
@NotNull EventLogGroup group,
|
||||
@Nullable FeatureUsageData context,
|
||||
@@ -90,16 +105,6 @@ public class FUStateUsagesLogger implements UsagesCollectorConsumer {
|
||||
return future;
|
||||
}
|
||||
|
||||
private static @NotNull CompletableFuture<Void> logCollectingUsageFailed(@Nullable Project project,
|
||||
@NotNull EventLogGroup group,
|
||||
@NotNull Throwable error) {
|
||||
if (project != null && project.isDisposed()) {
|
||||
return CompletableFuture.completedFuture(null);
|
||||
}
|
||||
return FeatureUsageLogger.INSTANCE.logState(group, EventLogSystemEvents.STATE_COLLECTOR_FAILED,
|
||||
new FeatureUsageData().addProject(project).build());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static FeatureUsageData addProject(@Nullable Project project,
|
||||
@Nullable FeatureUsageData context) {
|
||||
|
||||
Reference in New Issue
Block a user