Skip to content

Commit 907754c

Browse files
authored
telemetry(amazonq): drop collectFiles instrumentation aws#5725
## Problem - Follow up on the previous remove trackPerformance PR, we no longer need collectFiles telemetry since the data isn't reliable in the extension host - integ tests are failing because of this ## Solution - Remove the instrumentation
1 parent 8e01816 commit 907754c

File tree

3 files changed

+56
-87
lines changed

3 files changed

+56
-87
lines changed

packages/core/src/shared/telemetry/vscodeTelemetry.json

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,22 +1157,6 @@
11571157
"name": "function_call",
11581158
"description": "Represents a function call. In most cases this should wrap code with a run(), then you can add context.",
11591159
"metadata": [
1160-
{
1161-
"type": "userCpuUsage",
1162-
"required": false
1163-
},
1164-
{
1165-
"type": "systemCpuUsage",
1166-
"required": false
1167-
},
1168-
{
1169-
"type": "architecture",
1170-
"required": false
1171-
},
1172-
{
1173-
"type": "heapTotal",
1174-
"required": false
1175-
},
11761160
{
11771161
"type": "functionName",
11781162
"required": true

packages/core/src/shared/utilities/workspaceUtils.ts

Lines changed: 55 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import { sanitizeFilename } from './textUtilities'
1717
import { GitIgnoreAcceptor } from '@gerhobbelt/gitignore-parser'
1818
import * as parser from '@gerhobbelt/gitignore-parser'
1919
import fs from '../fs/fs'
20-
import { telemetry } from '../telemetry'
2120

2221
type GitIgnoreRelativeAcceptor = {
2322
folderPath: string
@@ -323,80 +322,70 @@ export async function collectFiles(
323322
zipFilePath: string
324323
}[]
325324
> {
326-
return telemetry.function_call.run(
327-
async (span) => {
328-
const storage: Awaited<ReturnType<typeof collectFiles>> = []
329-
330-
const workspaceFoldersMapping = getWorkspaceFoldersByPrefixes(workspaceFolders)
331-
const workspaceToPrefix = new Map<vscode.WorkspaceFolder, string>(
332-
workspaceFoldersMapping === undefined
333-
? [[workspaceFolders[0], '']]
334-
: Object.entries(workspaceFoldersMapping).map((value) => [value[1], value[0]])
335-
)
336-
const prefixWithFolderPrefix = (folder: vscode.WorkspaceFolder, path: string) => {
337-
const prefix = workspaceToPrefix.get(folder)
338-
/**
339-
* collects all files that are marked as source
340-
* @param sourcePaths the paths where collection starts
341-
* @param workspaceFolders the current workspace folders opened
342-
* @param respectGitIgnore whether to respect gitignore file
343-
* @returns all matched files
344-
*/
345-
if (prefix === undefined) {
346-
throw new ToolkitError(`Failed to find prefix for workspace folder ${folder.name}`)
347-
}
348-
return prefix === '' ? path : `${prefix}/${path}`
349-
}
325+
const storage: Awaited<ReturnType<typeof collectFiles>> = []
350326

351-
let totalSizeBytes = 0
352-
for (const rootPath of sourcePaths) {
353-
const allFiles = await vscode.workspace.findFiles(
354-
new vscode.RelativePattern(rootPath, '**'),
355-
getExcludePattern()
356-
)
327+
const workspaceFoldersMapping = getWorkspaceFoldersByPrefixes(workspaceFolders)
328+
const workspaceToPrefix = new Map<vscode.WorkspaceFolder, string>(
329+
workspaceFoldersMapping === undefined
330+
? [[workspaceFolders[0], '']]
331+
: Object.entries(workspaceFoldersMapping).map((value) => [value[1], value[0]])
332+
)
333+
const prefixWithFolderPrefix = (folder: vscode.WorkspaceFolder, path: string) => {
334+
const prefix = workspaceToPrefix.get(folder)
335+
/**
336+
* collects all files that are marked as source
337+
* @param sourcePaths the paths where collection starts
338+
* @param workspaceFolders the current workspace folders opened
339+
* @param respectGitIgnore whether to respect gitignore file
340+
* @returns all matched files
341+
*/
342+
if (prefix === undefined) {
343+
throw new ToolkitError(`Failed to find prefix for workspace folder ${folder.name}`)
344+
}
345+
return prefix === '' ? path : `${prefix}/${path}`
346+
}
357347

358-
const files = respectGitIgnore ? await filterOutGitignoredFiles(rootPath, allFiles) : allFiles
348+
let totalSizeBytes = 0
349+
for (const rootPath of sourcePaths) {
350+
const allFiles = await vscode.workspace.findFiles(
351+
new vscode.RelativePattern(rootPath, '**'),
352+
getExcludePattern()
353+
)
359354

360-
for (const file of files) {
361-
const relativePath = getWorkspaceRelativePath(file.fsPath, { workspaceFolders })
362-
if (!relativePath) {
363-
continue
364-
}
355+
const files = respectGitIgnore ? await filterOutGitignoredFiles(rootPath, allFiles) : allFiles
365356

366-
const fileStat = await fs.stat(file)
367-
if (totalSizeBytes + fileStat.size > maxSize) {
368-
throw new ToolkitError(
369-
'The project you have selected for source code is too large to use as context. Please select a different folder to use',
370-
{ code: 'ContentLengthError' }
371-
)
372-
}
357+
for (const file of files) {
358+
const relativePath = getWorkspaceRelativePath(file.fsPath, { workspaceFolders })
359+
if (!relativePath) {
360+
continue
361+
}
373362

374-
const fileContent = await readFile(file)
363+
const fileStat = await fs.stat(file)
364+
if (totalSizeBytes + fileStat.size > maxSize) {
365+
throw new ToolkitError(
366+
'The project you have selected for source code is too large to use as context. Please select a different folder to use',
367+
{ code: 'ContentLengthError' }
368+
)
369+
}
375370

376-
if (fileContent === undefined) {
377-
continue
378-
}
371+
const fileContent = await readFile(file)
379372

380-
// Now that we've read the file, increase our usage
381-
totalSizeBytes += fileStat.size
382-
storage.push({
383-
workspaceFolder: relativePath.workspaceFolder,
384-
relativeFilePath: relativePath.relativePath,
385-
fileUri: file,
386-
fileContent: fileContent,
387-
zipFilePath: prefixWithFolderPrefix(relativePath.workspaceFolder, relativePath.relativePath),
388-
})
389-
}
373+
if (fileContent === undefined) {
374+
continue
390375
}
391-
return storage
392-
},
393-
{
394-
emit: true,
395-
functionId: {
396-
name: 'collectFiles',
397-
},
376+
377+
// Now that we've read the file, increase our usage
378+
totalSizeBytes += fileStat.size
379+
storage.push({
380+
workspaceFolder: relativePath.workspaceFolder,
381+
relativeFilePath: relativePath.relativePath,
382+
fileUri: file,
383+
fileContent: fileContent,
384+
zipFilePath: prefixWithFolderPrefix(relativePath.workspaceFolder, relativePath.relativePath),
385+
})
398386
}
399-
)
387+
}
388+
return storage
400389
}
401390

402391
const readFile = async (file: vscode.Uri) => {

packages/core/src/testInteg/shared/utilities/workspaceUtils.test.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
import { getTestWorkspaceFolder } from '../../integrationTestsUtilities'
1717
import globals from '../../../shared/extensionGlobals'
1818
import { CodelensRootRegistry } from '../../../shared/fs/codelensRootRegistry'
19-
import { assertTelemetry, createTestWorkspace, createTestWorkspaceFolder, toFile } from '../../../test/testUtil'
19+
import { createTestWorkspace, createTestWorkspaceFolder, toFile } from '../../../test/testUtil'
2020
import sinon from 'sinon'
2121
import { performanceTest } from '../../../shared/performance/performance'
2222
import { randomUUID } from '../../../shared/crypto'
@@ -298,10 +298,6 @@ describe('collectFiles', function () {
298298
] satisfies typeof result,
299299
result
300300
)
301-
302-
assertTelemetry('function_call', {
303-
functionName: 'collectFiles',
304-
})
305301
})
306302

307303
it('does not return license files', async function () {

0 commit comments

Comments
 (0)