Skip to content

Commit b7bbdc4

Browse files
authored
make sure startup.resource.perf doesn't contain paths (microsoft#164812)
* make sure `startup.resource.perf` doesn't contain paths microsoft#164810 * use posix.basename...
1 parent 2f88e15 commit b7bbdc4

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

src/vs/workbench/contrib/performance/browser/performance.web.contribution.ts

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,39 @@ import { LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle
77
import { Registry } from 'vs/platform/registry/common/platform';
88
import { Extensions, IWorkbenchContributionsRegistry } from 'vs/workbench/common/contributions';
99
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
10+
import { posix } from 'vs/base/common/path';
11+
import { hash } from 'vs/base/common/hash';
1012

1113
class ResourcePerformanceMarks {
1214

1315
constructor(@ITelemetryService telemetryService: ITelemetryService) {
1416

15-
type Entry = { name: string; duration: number };
17+
type Entry = {
18+
hosthash: string;
19+
name: string;
20+
duration: number;
21+
};
1622
type EntryClassifify = {
1723
owner: 'jrieken';
1824
comment: 'Resource performance numbers';
19-
name: { classification: 'SystemMetaData'; purpose: 'PerformanceAndHealth'; comment: 'Resource name' };
25+
hosthash: { classification: 'SystemMetaData'; purpose: 'PerformanceAndHealth'; comment: 'Hash of the hostname' };
26+
name: { classification: 'SystemMetaData'; purpose: 'PerformanceAndHealth'; comment: 'Resource basename' };
2027
duration: { classification: 'SystemMetaData'; purpose: 'PerformanceAndHealth'; isMeasurement: true; comment: 'Resource duration' };
2128
};
2229
for (const item of performance.getEntriesByType('resource')) {
23-
telemetryService.publicLog2<Entry, EntryClassifify>('startup.resource.perf', {
24-
name: item.name,
25-
duration: item.duration
26-
});
30+
31+
try {
32+
const url = new URL(item.name);
33+
const name = posix.basename(url.pathname);
34+
35+
telemetryService.publicLog2<Entry, EntryClassifify>('startup.resource.perf', {
36+
hosthash: `H${hash(url.host).toString(16)}`,
37+
name,
38+
duration: item.duration
39+
});
40+
} catch {
41+
// ignore
42+
}
2743
}
2844
}
2945
}

0 commit comments

Comments
 (0)