mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[FreezeLogger] if flag is enabled send report to our stats server
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
+36
-6
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -141,6 +141,8 @@
|
||||
|
||||
<applicationService serviceInterface="com.intellij.featureStatistics.FeatureUsageTracker"
|
||||
serviceImplementation="com.intellij.featureStatistics.FeatureUsageTrackerImpl"/>
|
||||
<applicationService serviceInterface="com.intellij.reporting.FreezeLogger"
|
||||
serviceImplementation="com.intellij.reporting.FreezeLoggerImpl"/>
|
||||
<applicationService serviceInterface="com.intellij.featureStatistics.ProductivityFeaturesRegistry"
|
||||
serviceImplementation="com.intellij.featureStatistics.ProductivityFeaturesRegistryImpl"/>
|
||||
<applicationService serviceInterface="com.intellij.util.InstanceofCheckerGenerator"
|
||||
|
||||
@@ -809,3 +809,6 @@ javafx.fxml.controller.from.loader.description=Resolve FXML controllers specifie
|
||||
|
||||
low.memory.watcher.sync=true
|
||||
low.memory.watcher.sync.description=Whether LowMemoryWatcher runnables should be executed on the same thread that the low memory events come
|
||||
|
||||
typing.freeze.report.dumps=false
|
||||
typing.freeze.report.dumps.description=Automatically reports thread dumps to our statistics server
|
||||
|
||||
Reference in New Issue
Block a user