@@ -13,6 +13,7 @@ import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
1313import { IPanelService } from 'vs/workbench/services/panel/common/panelService' ;
1414import { IEditorService } from 'vs/workbench/services/editor/common/editorService' ;
1515import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility' ;
16+ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry' ;
1617
1718/* __GDPR__FRAGMENT__
1819 "IMemoryInfo" : {
@@ -308,18 +309,47 @@ export abstract class AbstractTimerService implements ITimerService {
308309 @IViewletService private readonly _viewletService : IViewletService ,
309310 @IPanelService private readonly _panelService : IPanelService ,
310311 @IEditorService private readonly _editorService : IEditorService ,
311- @IAccessibilityService private readonly _accessibilityService : IAccessibilityService
312+ @IAccessibilityService private readonly _accessibilityService : IAccessibilityService ,
313+ @ITelemetryService private readonly _telemetryService : ITelemetryService ,
312314 ) { }
313315
314316 get startupMetrics ( ) : Promise < IStartupMetrics > {
315317 if ( ! this . _startupMetrics ) {
316- this . _startupMetrics = Promise
317- . resolve ( this . _extensionService . whenInstalledExtensionsRegistered ( ) )
318- . then ( ( ) => this . _computeStartupMetrics ( ) ) ;
318+ this . _startupMetrics = this . _extensionService . whenInstalledExtensionsRegistered ( )
319+ . then ( ( ) => this . _computeStartupMetrics ( ) )
320+ . then ( metrics => {
321+ this . _reportStartupTimes ( metrics ) ;
322+ return metrics ;
323+ } ) ;
319324 }
320325 return this . _startupMetrics ;
321326 }
322327
328+ private _reportStartupTimes ( metrics : IStartupMetrics ) : void {
329+
330+ // report IStartupMetrics as telemetry
331+ /* __GDPR__
332+ "startupTimeVaried" : {
333+ "${include}": [
334+ "${IStartupMetrics}"
335+ ]
336+ }
337+ */
338+ this . _telemetryService . publicLog ( 'startupTimeVaried' , metrics ) ;
339+
340+ // report raw timers as telemetry
341+ const entries : Record < string , number > = Object . create ( null ) ;
342+ for ( const entry of perf . getEntries ( ) ) {
343+ entries [ entry . name ] = entry . startTime ;
344+ }
345+ /* __GDPR__
346+ "startupRawTimers" : {
347+ "entries": { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth" }
348+ }
349+ */
350+ this . _telemetryService . publicLog ( 'startupRawTimers' , { entries } ) ;
351+ }
352+
323353 private async _computeStartupMetrics ( ) : Promise < IStartupMetrics > {
324354
325355 const now = Date . now ( ) ;
@@ -337,7 +367,7 @@ export abstract class AbstractTimerService implements ITimerService {
337367 didUseCachedData : this . _didUseCachedData ( ) ,
338368 windowKind : this . _lifecycleService . startupKind ,
339369 windowCount : await this . _getWindowCount ( ) ,
340- viewletId : activeViewlet ? activeViewlet . getId ( ) : undefined ,
370+ viewletId : activeViewlet ? .getId ( ) ,
341371 editorIds : this . _editorService . visibleEditors . map ( input => input . getTypeId ( ) ) ,
342372 panelId : activePanel ? activePanel . getId ( ) : undefined ,
343373
0 commit comments