Skip to content

Commit be8b201

Browse files
authored
Fix the perf trace collection issues (#1147)
* Avoid the LSP request name get redacted * Only collect data from last session --------- Signed-off-by: Sheng Chen <[email protected]>
1 parent 6602e37 commit be8b201

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

src/daemon/clientLog/logWatcher.ts

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,20 @@ export class ClientLogWatcher {
2727
}
2828

2929
public async collectInfoFromLog() {
30-
const logs = await this.getLogs();
30+
let logs = await this.getLogs();
3131
if (logs) {
32+
logs = logs.reverse();
33+
let sessionCount = 0;
3234
for (const log of logs) {
33-
if (log.message?.startsWith("Use the JDK from") && Date.parse(log.timestamp) > this.logProcessedTimestamp) {
35+
if (log.message?.startsWith("Use the JDK from")) {
36+
if (++sessionCount > 1) {
37+
// only the lsp traces from last session should be collected.
38+
break;
39+
}
40+
41+
if (Date.parse(log.timestamp) < this.logProcessedTimestamp) {
42+
continue;
43+
}
3444
const info: any = {};
3545
info.defaultProjectJdk = log?.message.replace("Use the JDK from '", "").replace("' as the initial default project JDK.", "");
3646

@@ -68,7 +78,7 @@ export class ClientLogWatcher {
6878
if (match?.length === 2) {
6979
sendInfo("", {
7080
name: "perf-trace",
71-
kind: key.replace("\\", ""),
81+
kind: escapeLspRequestName(key),
7282
time: match[1],
7383
});
7484
}
@@ -151,4 +161,11 @@ function parse(rawLog: string) {
151161
}
152162
}
153163
return ret;
164+
}
165+
166+
/**
167+
* To avoid the LSP request name get redacted.
168+
*/
169+
function escapeLspRequestName(name: string) {
170+
return name.replace("\\/", "-");
154171
}

0 commit comments

Comments
 (0)