diff --git a/platform/platform-api/src/com/intellij/openapi/editor/actionSystem/TypedAction.java b/platform/platform-api/src/com/intellij/openapi/editor/actionSystem/TypedAction.java index 5fa1eb211f74..7adff76945de 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/actionSystem/TypedAction.java +++ b/platform/platform-api/src/com/intellij/openapi/editor/actionSystem/TypedAction.java @@ -24,6 +24,7 @@ import com.intellij.openapi.command.UndoConfirmationPolicy; import com.intellij.openapi.editor.*; import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.project.Project; +import com.intellij.reporting.FreezeLogger; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -132,7 +133,7 @@ public class TypedAction { public final void actionPerformed(@Nullable final Editor editor, final char charTyped, final DataContext dataContext) { if (editor == null) return; Project project = CommonDataKeys.PROJECT.getData(dataContext); - FreezeLogger.runUnderPerformanceMonitor(project, () -> myRawHandler.execute(editor, charTyped, dataContext)); + FreezeLogger.getInstance().runUnderPerformanceMonitor(project, () -> myRawHandler.execute(editor, charTyped, dataContext)); } private class DefaultRawHandler implements TypedActionHandler { diff --git a/platform/platform-api/src/com/intellij/reporting/FreezeLogger.java b/platform/platform-api/src/com/intellij/reporting/FreezeLogger.java new file mode 100644 index 000000000000..7db0f94b6297 --- /dev/null +++ b/platform/platform-api/src/com/intellij/reporting/FreezeLogger.java @@ -0,0 +1,31 @@ +/* + * Copyright 2000-2016 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.reporting; + +import com.intellij.openapi.components.ServiceManager; +import com.intellij.openapi.project.Project; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public abstract class FreezeLogger { + + public static FreezeLogger getInstance() { + return ServiceManager.getService(FreezeLogger.class); + } + + public abstract void runUnderPerformanceMonitor(@Nullable Project project, @NotNull Runnable action); + +} diff --git a/platform/platform-api/src/com/intellij/openapi/editor/actionSystem/FreezeLogger.java b/platform/platform-impl/src/com/intellij/reporting/FreezeLoggerImpl.java similarity index 63% rename from platform/platform-api/src/com/intellij/openapi/editor/actionSystem/FreezeLogger.java rename to platform/platform-impl/src/com/intellij/reporting/FreezeLoggerImpl.java index 31567aade6b0..2c9214a6d238 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/actionSystem/FreezeLogger.java +++ b/platform/platform-impl/src/com/intellij/reporting/FreezeLoggerImpl.java @@ -13,25 +13,28 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.intellij.openapi.editor.actionSystem; +package com.intellij.reporting; import com.intellij.diagnostic.ThreadDumper; +import com.intellij.openapi.application.ApplicationInfo; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.DumbService; import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.registry.Registry; import com.intellij.util.Alarm; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -public class FreezeLogger { +public class FreezeLoggerImpl extends FreezeLogger { - private static final Logger LOG = Logger.getInstance(FreezeLogger.class); + private static final Logger LOG = Logger.getInstance(FreezeLoggerImpl.class); private static final Alarm ALARM = new Alarm(Alarm.ThreadToUse.POOLED_THREAD, ApplicationManager.getApplication()); private static final int MAX_ALLOWED_TIME = 500; - public static void runUnderPerformanceMonitor(@Nullable Project project, @NotNull Runnable action) { + @Override + public void runUnderPerformanceMonitor(@Nullable Project project, @NotNull Runnable action) { if (ApplicationManager.getApplication().isUnitTestMode()) { action.run(); return; @@ -64,8 +67,35 @@ public class FreezeLogger { final String msg = "Typing freeze report, (DumbMode=" + isInDumbMode + ") thread dumps attached. EDT stacktrace:\n" + edtTrace + "\n\n\n"; - - LOG.error(msg, dumps); + + if (Registry.is("typing.freeze.report.dumps")) { + ThreadDumpInfo info = new ThreadDumpInfo(dumps, isInDumbMode); + String report = ReporterKt.createReportLine("typing-freeze-dumps", info); + if (!StatsSender.INSTANCE.send(report, true)) { + LOG.debug("Error while reporting thread dump"); + } + } + else { + LOG.error(msg, dumps); + } } +} + +class ThreadDumpInfo { + public final String dump; + public final String version; + public final String product; + public final String buildNumber; + public final boolean isEAP; + public final boolean isInDumbMode; + + public ThreadDumpInfo(String dump, boolean isInDumbMode) { + this.dump = dump; + this.product = ApplicationInfo.getInstance().getVersionName(); + this.version = ApplicationInfo.getInstance().getFullVersion(); + this.buildNumber = ApplicationInfo.getInstance().getBuild().toString(); + this.isEAP = ApplicationManager.getApplication().isEAP(); + this.isInDumbMode = isInDumbMode; + } } \ No newline at end of file diff --git a/platform/platform-resources/src/META-INF/PlatformExtensions.xml b/platform/platform-resources/src/META-INF/PlatformExtensions.xml index 4c2e426a25c4..b7970bf6bcbf 100644 --- a/platform/platform-resources/src/META-INF/PlatformExtensions.xml +++ b/platform/platform-resources/src/META-INF/PlatformExtensions.xml @@ -141,6 +141,8 @@ +