Skip to content

Commit

Permalink
let timer service report perf telemetry, #101850
Browse files Browse the repository at this point in the history
  • Loading branch information
jrieken committed Jul 9, 2020
1 parent 2122093 commit fffa94d
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import { IEditorService } from 'vs/workbench/services/editor/common/editorServic
import { IPanelService } from 'vs/workbench/services/panel/common/panelService';
import { didUseCachedData } from 'vs/workbench/services/timer/electron-browser/timerService';
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
import { getEntries } from 'vs/base/common/performance';
import { ITimerService } from 'vs/workbench/services/timer/browser/timerService';

export class StartupTimings implements IWorkbenchContribution {
Expand All @@ -44,22 +43,7 @@ export class StartupTimings implements IWorkbenchContribution {

private async _report() {
const standardStartupError = await this._isStandardStartup();
this._reportStartupTimes().catch(onUnexpectedError);
this._appendStartupTimes(standardStartupError).catch(onUnexpectedError);
this._reportPerfTicks();
}

private async _reportStartupTimes(): Promise<void> {
const metrics = await this._timerService.startupMetrics;

/* __GDPR__
"startupTimeVaried" : {
"${include}": [
"${IStartupMetrics}"
]
}
*/
this._telemetryService.publicLog('startupTimeVaried', metrics);
}

private async _appendStartupTimes(standardStartupError: string | undefined) {
Expand Down Expand Up @@ -121,17 +105,4 @@ export class StartupTimings implements IWorkbenchContribution {
}
return undefined;
}

private _reportPerfTicks(): void {
const entries: Record<string, number> = Object.create(null);
for (const entry of getEntries()) {
entries[entry.name] = entry.startTime;
}
/* __GDPR__
"startupRawTimers" : {
"entries": { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth" }
}
*/
this._telemetryService.publicLog('startupRawTimers', { entries });
}
}
40 changes: 35 additions & 5 deletions src/vs/workbench/services/timer/browser/timerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
import { IPanelService } from 'vs/workbench/services/panel/common/panelService';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';

/* __GDPR__FRAGMENT__
"IMemoryInfo" : {
Expand Down Expand Up @@ -308,18 +309,47 @@ export abstract class AbstractTimerService implements ITimerService {
@IViewletService private readonly _viewletService: IViewletService,
@IPanelService private readonly _panelService: IPanelService,
@IEditorService private readonly _editorService: IEditorService,
@IAccessibilityService private readonly _accessibilityService: IAccessibilityService
@IAccessibilityService private readonly _accessibilityService: IAccessibilityService,
@ITelemetryService private readonly _telemetryService: ITelemetryService,
) { }

get startupMetrics(): Promise<IStartupMetrics> {
if (!this._startupMetrics) {
this._startupMetrics = Promise
.resolve(this._extensionService.whenInstalledExtensionsRegistered())
.then(() => this._computeStartupMetrics());
this._startupMetrics = this._extensionService.whenInstalledExtensionsRegistered()
.then(() => this._computeStartupMetrics())
.then(metrics => {
this._reportStartupTimes(metrics);
return metrics;
});
}
return this._startupMetrics;
}

private _reportStartupTimes(metrics: IStartupMetrics): void {

// report IStartupMetrics as telemetry
/* __GDPR__
"startupTimeVaried" : {
"${include}": [
"${IStartupMetrics}"
]
}
*/
this._telemetryService.publicLog('startupTimeVaried', metrics);

// report raw timers as telemetry
const entries: Record<string, number> = Object.create(null);
for (const entry of perf.getEntries()) {
entries[entry.name] = entry.startTime;
}
/* __GDPR__
"startupRawTimers" : {
"entries": { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth" }
}
*/
this._telemetryService.publicLog('startupRawTimers', { entries });
}

private async _computeStartupMetrics(): Promise<IStartupMetrics> {

const now = Date.now();
Expand All @@ -337,7 +367,7 @@ export abstract class AbstractTimerService implements ITimerService {
didUseCachedData: this._didUseCachedData(),
windowKind: this._lifecycleService.startupKind,
windowCount: await this._getWindowCount(),
viewletId: activeViewlet ? activeViewlet.getId() : undefined,
viewletId: activeViewlet?.getId(),
editorIds: this._editorService.visibleEditors.map(input => input.getTypeId()),
panelId: activePanel ? activePanel.getId() : undefined,

Expand Down

0 comments on commit fffa94d

Please sign in to comment.