Skip to content

Commit 2f5d65d

Browse files
committed
refactor(core): Remove withPerformance from telemetry
Problem: - withPerformance was an experiment to see if we could correlate cpu/memory with number of files Solution: - Cpu usage/memory usage in the extension host is way too volitile so we might as well clean up this code
1 parent 486dd03 commit 2f5d65d

File tree

5 files changed

+2
-58
lines changed

5 files changed

+2
-58
lines changed

packages/core/src/shared/performance/performance.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
import assert from 'assert'
77
import { getLogger } from '../logger'
8-
import { isWeb } from '../extensionGlobals'
98

109
interface PerformanceMetrics {
1110
/**
@@ -46,10 +45,6 @@ export class PerformanceTracker {
4645

4746
constructor(private readonly name: string) {}
4847

49-
static enabled(name: string, trackPerformance: boolean): boolean {
50-
return name === 'function_call' && trackPerformance && !isWeb()
51-
}
52-
5348
start() {
5449
this.#startPerformance = {
5550
cpuUsage: process.cpuUsage(),

packages/core/src/shared/telemetry/spans.ts

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import {
2323
getTelemetryResult,
2424
} from '../errors'
2525
import { entries, NumericKeys } from '../utilities/tsUtils'
26-
import { PerformanceTracker } from '../performance/performance'
2726
import { randomUUID } from '../crypto'
2827

2928
const AsyncLocalStorage: typeof AsyncLocalStorageClass =
@@ -135,10 +134,7 @@ export type SpanOptions = {
135134
*/
136135
export class TelemetrySpan<T extends MetricBase = MetricBase> {
137136
#startTime?: Date
138-
#options: SpanOptions & {
139-
trackPerformance: boolean
140-
}
141-
#performance?: PerformanceTracker
137+
#options: SpanOptions
142138

143139
private readonly state: Partial<T> = {}
144140
private readonly definition = definitions[this.name] ?? {
@@ -163,10 +159,6 @@ export class TelemetrySpan<T extends MetricBase = MetricBase> {
163159
// do emit by default
164160
emit: options?.emit === undefined ? true : options.emit,
165161
functionId: options?.functionId,
166-
trackPerformance: PerformanceTracker.enabled(
167-
this.name,
168-
this.definition.trackPerformance && (options?.emit ?? false) // only track the performance if we are also emitting
169-
),
170162
}
171163

172164
this.metricId = randomUUID()
@@ -209,10 +201,6 @@ export class TelemetrySpan<T extends MetricBase = MetricBase> {
209201
*/
210202
public start(): this {
211203
this.#startTime = new globals.clock.Date()
212-
if (this.#options.trackPerformance) {
213-
;(this.#performance ??= new PerformanceTracker(this.name)).start()
214-
}
215-
216204
return this
217205
}
218206

@@ -224,21 +212,6 @@ export class TelemetrySpan<T extends MetricBase = MetricBase> {
224212
public stop(err?: unknown): void {
225213
const duration = this.startTime !== undefined ? globals.clock.Date.now() - this.startTime.getTime() : undefined
226214

227-
if (this.#options.trackPerformance) {
228-
// TODO add these to the global metrics, right now it just forces them in the telemetry and ignores the type
229-
// if someone enables this action
230-
const performanceMetrics = this.#performance?.stop()
231-
if (performanceMetrics) {
232-
this.record({
233-
userCpuUsage: performanceMetrics.userCpuUsage,
234-
systemCpuUsage: performanceMetrics.systemCpuUsage,
235-
heapTotal: performanceMetrics.heapTotal,
236-
functionName: this.#options.functionId?.name ?? this.name,
237-
architecture: process.arch,
238-
} as any)
239-
}
240-
}
241-
242215
if (this.#options.emit) {
243216
this.emit({
244217
duration,

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

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -307,16 +307,6 @@
307307
"type": "string",
308308
"description": "The CPU architecture"
309309
},
310-
{
311-
"name": "totalFileSizeInMB",
312-
"type": "int",
313-
"description": "The total size of all files being sent to Amazon Q"
314-
},
315-
{
316-
"name": "totalFiles",
317-
"type": "int",
318-
"description": "The total number of files being sent to Amazon Q"
319-
},
320310
{
321311
"name": "traceId",
322312
"type": "string",
@@ -1165,14 +1155,6 @@
11651155
"type": "systemCpuUsage",
11661156
"required": false
11671157
},
1168-
{
1169-
"type": "totalFiles",
1170-
"required": false
1171-
},
1172-
{
1173-
"type": "totalFileSizeInMB",
1174-
"required": false
1175-
},
11761158
{
11771159
"type": "architecture",
11781160
"required": false
@@ -1186,8 +1168,7 @@
11861168
"required": true
11871169
}
11881170
],
1189-
"passive": true,
1190-
"trackPerformance": true
1171+
"passive": true
11911172
},
11921173
{
11931174
"name": "webview_load",

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -344,15 +344,13 @@ export async function collectFiles(
344344
}
345345

346346
let totalSizeBytes = 0
347-
let totalFiles = 0
348347
for (const rootPath of sourcePaths) {
349348
const allFiles = await vscode.workspace.findFiles(
350349
new vscode.RelativePattern(rootPath, '**'),
351350
getExcludePattern()
352351
)
353352

354353
const files = respectGitIgnore ? await filterOutGitignoredFiles(rootPath, allFiles) : allFiles
355-
totalFiles += files.length
356354

357355
for (const file of files) {
358356
const relativePath = getWorkspaceRelativePath(file.fsPath, { workspaceFolders })
@@ -385,7 +383,6 @@ export async function collectFiles(
385383
})
386384
}
387385
}
388-
span.record({ totalFiles, totalFileSizeInMB: totalSizeBytes / (1024 * 1024) })
389386
return storage
390387
},
391388
{

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,8 +301,6 @@ describe('collectFiles', function () {
301301
)
302302

303303
assertTelemetry('function_call', {
304-
totalFiles: 8,
305-
totalFileSizeInMB: 0.0002593994140625,
306304
functionName: 'collectFiles',
307305
})
308306
})

0 commit comments

Comments
 (0)