Skip to content

Commit

Permalink
make sure startup.resource.perf doesn't contain paths (#164812)
Browse files Browse the repository at this point in the history
* make sure `startup.resource.perf` doesn't contain paths

#164810

* use posix.basename...
  • Loading branch information
jrieken authored Oct 27, 2022
1 parent 2f88e15 commit b7bbdc4
Showing 1 changed file with 22 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,39 @@ import { LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle
import { Registry } from 'vs/platform/registry/common/platform';
import { Extensions, IWorkbenchContributionsRegistry } from 'vs/workbench/common/contributions';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { posix } from 'vs/base/common/path';
import { hash } from 'vs/base/common/hash';

class ResourcePerformanceMarks {

constructor(@ITelemetryService telemetryService: ITelemetryService) {

type Entry = { name: string; duration: number };
type Entry = {
hosthash: string;
name: string;
duration: number;
};
type EntryClassifify = {
owner: 'jrieken';
comment: 'Resource performance numbers';
name: { classification: 'SystemMetaData'; purpose: 'PerformanceAndHealth'; comment: 'Resource name' };
hosthash: { classification: 'SystemMetaData'; purpose: 'PerformanceAndHealth'; comment: 'Hash of the hostname' };
name: { classification: 'SystemMetaData'; purpose: 'PerformanceAndHealth'; comment: 'Resource basename' };
duration: { classification: 'SystemMetaData'; purpose: 'PerformanceAndHealth'; isMeasurement: true; comment: 'Resource duration' };
};
for (const item of performance.getEntriesByType('resource')) {
telemetryService.publicLog2<Entry, EntryClassifify>('startup.resource.perf', {
name: item.name,
duration: item.duration
});

try {
const url = new URL(item.name);
const name = posix.basename(url.pathname);

telemetryService.publicLog2<Entry, EntryClassifify>('startup.resource.perf', {
hosthash: `H${hash(url.host).toString(16)}`,
name,
duration: item.duration
});
} catch {
// ignore
}
}
}
}
Expand Down

0 comments on commit b7bbdc4

Please sign in to comment.