diff --git a/src/vs/platform/search/common/search.ts b/src/vs/platform/search/common/search.ts index 288f124c21e..9392a486e27 100644 --- a/src/vs/platform/search/common/search.ts +++ b/src/vs/platform/search/common/search.ts @@ -73,6 +73,9 @@ export interface IFolderQuery { } export interface ICommonQueryProps { + /** For telemetry - indicates what is triggering the source */ + _reason?: string; + folderQueries?: IFolderQuery[]; includePattern?: glob.IExpression; excludePattern?: glob.IExpression; diff --git a/src/vs/workbench/api/electron-browser/mainThreadWorkspace.ts b/src/vs/workbench/api/electron-browser/mainThreadWorkspace.ts index e9b5d62fc1b..b5828cf89b9 100644 --- a/src/vs/workbench/api/electron-browser/mainThreadWorkspace.ts +++ b/src/vs/workbench/api/electron-browser/mainThreadWorkspace.ts @@ -150,7 +150,8 @@ export class MainThreadWorkspace implements MainThreadWorkspaceShape { type: QueryType.File, maxResults, disregardExcludeSettings: excludePatternOrDisregardExcludes === false, - useRipgrep + useRipgrep, + _reason: 'startFileSearch' }; if (typeof includePattern === 'string') { query.includePattern = { [includePattern]: true }; @@ -178,6 +179,7 @@ export class MainThreadWorkspace implements MainThreadWorkspaceShape { const queryBuilder = this._instantiationService.createInstance(QueryBuilder); const query = queryBuilder.text(pattern, folders, options); + query._reason = 'startTextSearch'; const onProgress = (p: ISearchProgressItem) => { if (p.matches) { @@ -204,6 +206,7 @@ export class MainThreadWorkspace implements MainThreadWorkspaceShape { const queryBuilder = this._instantiationService.createInstance(QueryBuilder); const folders = this._contextService.getWorkspace().folders.map(folder => folder.uri); const query = queryBuilder.file(folders, { + _reason: 'checkExists', includePattern: includes.join(', '), exists: true }); diff --git a/src/vs/workbench/parts/search/browser/openFileHandler.ts b/src/vs/workbench/parts/search/browser/openFileHandler.ts index 8c6d8ab843c..ec191af0f51 100644 --- a/src/vs/workbench/parts/search/browser/openFileHandler.ts +++ b/src/vs/workbench/parts/search/browser/openFileHandler.ts @@ -202,6 +202,7 @@ export class OpenFileHandler extends QuickOpenHandler { private doResolveQueryOptions(query: IPreparedQuery, cacheKey?: string, maxSortedResults?: number): IFileQueryBuilderOptions { const queryOptions: IFileQueryBuilderOptions = { + _reason: 'openFileHandler', extraFileResources: getOutOfWorkspaceEditorResources(this.editorService, this.contextService), filePattern: query.value, cacheKey @@ -226,6 +227,7 @@ export class OpenFileHandler extends QuickOpenHandler { private cacheQuery(cacheKey: string): IFileQuery { const options: IFileQueryBuilderOptions = { + _reason: 'openFileHandler', extraFileResources: getOutOfWorkspaceEditorResources(this.editorService, this.contextService), filePattern: '', cacheKey: cacheKey, diff --git a/src/vs/workbench/parts/search/browser/searchView.ts b/src/vs/workbench/parts/search/browser/searchView.ts index 0d52f6c9fa5..8e8b1cb18c8 100644 --- a/src/vs/workbench/parts/search/browser/searchView.ts +++ b/src/vs/workbench/parts/search/browser/searchView.ts @@ -1053,6 +1053,7 @@ export class SearchView extends Viewlet implements IViewlet, IPanel { 250; const options: ITextQueryBuilderOptions = { + _reason: 'searchView', extraFileResources: getOutOfWorkspaceEditorResources(this.editorService, this.contextService), maxResults: SearchView.MAX_TEXT_RESULTS, disregardIgnoreFiles: !useExcludesAndIgnoreFiles, diff --git a/src/vs/workbench/parts/search/common/queryBuilder.ts b/src/vs/workbench/parts/search/common/queryBuilder.ts index a5555d4a033..fec05d60ad5 100644 --- a/src/vs/workbench/parts/search/common/queryBuilder.ts +++ b/src/vs/workbench/parts/search/common/queryBuilder.ts @@ -30,6 +30,7 @@ export interface ISearchPathsResult { } export interface ICommonQueryBuilderOptions { + _reason?: string; excludePattern?: string; includePattern?: string; extraFileResources?: uri[]; @@ -115,6 +116,7 @@ export class QueryBuilder { }); const queryProps: ICommonQueryProps = { + _reason: options._reason, folderQueries: folderQueries || [], usingSearchPaths: !!(searchPaths && searchPaths.length), extraFileResources: options.extraFileResources, diff --git a/src/vs/workbench/services/search/node/searchService.ts b/src/vs/workbench/services/search/node/searchService.ts index 3a9cfc19414..fcddb7cb17f 100644 --- a/src/vs/workbench/services/search/node/searchService.ts +++ b/src/vs/workbench/services/search/node/searchService.ts @@ -121,7 +121,7 @@ export class SearchService extends Disposable implements ISearchService { return this.doSearch(query, token); } - private doSearch(query: ITextQuery | IFileQuery, token?: CancellationToken, onProgress?: (item: ISearchProgressItem) => void): TPromise { + private doSearch(query: ISearchQuery, token?: CancellationToken, onProgress?: (item: ISearchProgressItem) => void): TPromise { const schemesInQuery = this.getSchemesInQuery(query); const providerActivations: TPromise[] = [TPromise.wrap(null)]; @@ -266,6 +266,7 @@ export class SearchService extends Disposable implements ISearchService { /* __GDPR__ "cachedSearchComplete" : { + "reason" : { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth" }, "resultCount" : { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth", "isMeasurement": true }, "workspaceFolderCount" : { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth", "isMeasurement": true }, "type" : { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth" }, @@ -279,6 +280,7 @@ export class SearchService extends Disposable implements ISearchService { } */ this.telemetryService.publicLog('cachedSearchComplete', { + reason: query._reason, resultCount: fileSearchStats.resultCount, workspaceFolderCount: query.folderQueries.length, type: fileSearchStats.type, @@ -295,6 +297,7 @@ export class SearchService extends Disposable implements ISearchService { /* __GDPR__ "searchComplete" : { + "reason" : { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth" }, "resultCount" : { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth", "isMeasurement": true }, "workspaceFolderCount" : { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth", "isMeasurement": true }, "type" : { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth" }, @@ -310,6 +313,7 @@ export class SearchService extends Disposable implements ISearchService { } */ this.telemetryService.publicLog('searchComplete', { + reason: query._reason, resultCount: fileSearchStats.resultCount, workspaceFolderCount: query.folderQueries.length, type: fileSearchStats.type,