@@ -75,7 +75,8 @@ import { IBroadcastService, BroadcastService } from 'vs/platform/broadcast/elect
7575import { HashService } from 'vs/workbench/services/hash/node/hashService' ;
7676import { IHashService } from 'vs/workbench/services/hash/common/hashService' ;
7777import { ILogService } from 'vs/platform/log/common/log' ;
78- import { IStorageService } from 'vs/platform/storage/common/storage' ;
78+ import { IStorageService , StorageScope } from 'vs/platform/storage/common/storage' ;
79+ import { DelegatingStorageService } from 'vs/platform/storage/electron-browser/storageService' ;
7980import { Event , Emitter } from 'vs/base/common/event' ;
8081import { WORKBENCH_BACKGROUND } from 'vs/workbench/common/theme' ;
8182import { ILocalizationsChannel , LocalizationsChannelClient } from 'vs/platform/localizations/node/localizationsIpc' ;
@@ -109,7 +110,7 @@ export interface ICoreServices {
109110 environmentService : IEnvironmentService ;
110111 logService : ILogService ;
111112 storageLegacyService : IStorageLegacyService ;
112- storageService : IStorageService ;
113+ storageService : DelegatingStorageService ;
113114}
114115
115116/**
@@ -122,7 +123,7 @@ export class WorkbenchShell extends Disposable {
122123 get onShutdown ( ) : Event < ShutdownEvent > { return this . _onShutdown . event ; }
123124
124125 private storageLegacyService : IStorageLegacyService ;
125- private storageService : IStorageService ;
126+ private storageService : DelegatingStorageService ;
126127 private environmentService : IEnvironmentService ;
127128 private logService : ILogService ;
128129 private configurationService : IConfigurationService ;
@@ -217,6 +218,11 @@ export class WorkbenchShell extends Disposable {
217218 // Startup Telemetry
218219 this . logStartupTelemetry ( startupInfos ) ;
219220
221+ // Storage Telemetry (TODO@Ben remove me later, including storage errors)
222+ if ( ! this . environmentService . extensionTestsPath ) {
223+ this . logStorageTelemetry ( ) ;
224+ }
225+
220226 // Set lifecycle phase to `Runnning For A Bit` after a short delay
221227 let eventuallPhaseTimeoutHandle = runWhenIdle ( ( ) => {
222228 eventuallPhaseTimeoutHandle = void 0 ;
@@ -277,6 +283,60 @@ export class WorkbenchShell extends Disposable {
277283 perf . mark ( 'didStartWorkbench' ) ;
278284 }
279285
286+ private logStorageTelemetry ( ) : void {
287+ const globalStorageInitDuration = perf . getDuration ( 'willInitGlobalStorage' , 'didInitGlobalStorage' ) ;
288+ const workspaceStorageInitDuration = perf . getDuration ( 'willInitWorkspaceStorage' , 'didInitWorkspaceStorage' ) ;
289+ const workbenchLoadDuration = perf . getDuration ( 'willLoadWorkbenchMain' , 'didLoadWorkbenchMain' ) ;
290+
291+ /* __GDPR__
292+ "sqliteStorageTimers" : {
293+ "globalReadTime" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true },
294+ "workspaceReadTime" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true },
295+ "globalKeys" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true },
296+ "workspaceKeys" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true },
297+ "startupKind": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true }
298+ }
299+ */
300+ this . telemetryService . publicLog ( 'sqliteStorageTimers' , {
301+ 'globalReadTime' : globalStorageInitDuration ,
302+ 'workspaceReadTime' : workspaceStorageInitDuration ,
303+ 'workbenchRequireTime' : workbenchLoadDuration ,
304+ 'globalKeys' : this . storageService . storage . getSize ( StorageScope . GLOBAL ) ,
305+ 'workspaceKeys' : this . storageService . storage . getSize ( StorageScope . WORKSPACE ) ,
306+ 'startupKind' : this . lifecycleService . startupKind
307+ } ) ;
308+
309+ // Handle errors (avoid duplicates to reduce spam)
310+ const loggedStorageErrors = new Set < string > ( ) ;
311+ this . _register ( this . storageService . storage . onStorageError ( error => {
312+ const errorStr = `${ error } ` ;
313+
314+ if ( ! loggedStorageErrors . has ( errorStr ) ) {
315+ loggedStorageErrors . add ( errorStr ) ;
316+
317+ /* __GDPR__
318+ "sqliteStorageError" : {
319+ "globalReadTime" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true },
320+ "workspaceReadTime" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true },
321+ "globalKeys" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true },
322+ "workspaceKeys" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true },
323+ "startupKind": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true },
324+ "storageError": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true }
325+ }
326+ */
327+ this . telemetryService . publicLog ( 'sqliteStorageError' , {
328+ 'globalReadTime' : globalStorageInitDuration ,
329+ 'workspaceReadTime' : workspaceStorageInitDuration ,
330+ 'workbenchRequireTime' : workbenchLoadDuration ,
331+ 'globalKeys' : this . storageService . storage . getSize ( StorageScope . GLOBAL ) ,
332+ 'workspaceKeys' : this . storageService . storage . getSize ( StorageScope . WORKSPACE ) ,
333+ 'startupKind' : this . lifecycleService . startupKind ,
334+ 'storageError' : errorStr
335+ } ) ;
336+ }
337+ } ) ) ;
338+ }
339+
280340 private initServiceCollection ( container : HTMLElement ) : [ IInstantiationService , ServiceCollection ] {
281341 const serviceCollection = new ServiceCollection ( ) ;
282342 serviceCollection . set ( IWorkspaceContextService , this . contextService ) ;
0 commit comments