Skip to content

Commit 161815b

Browse files
committed
Report only one instance of a logged error through telemetry.
Signed-off-by: Roland Grunberg <[email protected]>
1 parent 02b046f commit 161815b

File tree

1 file changed

+14
-2
lines changed
  • org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/handlers

1 file changed

+14
-2
lines changed

org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/handlers/LogHandler.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
import java.text.DateFormat;
2121
import java.util.ArrayList;
2222
import java.util.Date;
23+
import java.util.HashSet;
2324
import java.util.List;
25+
import java.util.Set;
2426
import java.util.function.Predicate;
2527

2628
import org.eclipse.core.resources.IWorkspaceRoot;
@@ -61,6 +63,7 @@ public class LogHandler {
6163
private String firstRecordedEntryDateString;
6264

6365
private List<IStatus> statusCache = new ArrayList<>();
66+
private Set<Integer> knownErrors = new HashSet<>();
6467

6568
/**
6669
* Equivalent to <code>LogHandler(defaultLogFilter)</code>.
@@ -106,6 +109,7 @@ public void setClientConnection(JavaClientConnection clientConnection) {
106109
for (IStatus event : statusCache) {
107110
processLogMessage(event);
108111
}
112+
statusCache.clear();
109113

110114
for (LogEntry e : entries) {
111115
processLogMessage(e);
@@ -139,7 +143,11 @@ private void processLogMessage(LogEntry entry) {
139143
if (entry.getStack() != null) {
140144
properties.addProperty("exception", message);
141145
}
142-
connection.telemetryEvent(new TelemetryEvent(JAVA_ERROR_LOG, properties));
146+
int hashCode = properties.hashCode();
147+
if (!knownErrors.contains(hashCode)) {
148+
knownErrors.add(hashCode);
149+
connection.telemetryEvent(new TelemetryEvent(JAVA_ERROR_LOG, properties));
150+
}
143151
}
144152
}
145153
private void processLogMessage(IStatus status) {
@@ -165,7 +173,11 @@ private void processLogMessage(IStatus status) {
165173
if (status.getException() != null) {
166174
properties.addProperty("exception", message);
167175
}
168-
connection.telemetryEvent(new TelemetryEvent(JAVA_ERROR_LOG, properties));
176+
int hashCode = properties.hashCode();
177+
if (!knownErrors.contains(hashCode)) {
178+
knownErrors.add(hashCode);
179+
connection.telemetryEvent(new TelemetryEvent(JAVA_ERROR_LOG, properties));
180+
}
169181
}
170182
}
171183

0 commit comments

Comments
 (0)