Conversation
There was a problem hiding this comment.
Pull request overview
Adds opt-in telemetry emission from the native TypeScript language server to help measure project characteristics and ongoing runtime/performance behavior (memory/GC/auto-import stats), with a new initialization option to enable/disable telemetry.
Changes:
- Introduces
enableTelemetryinitialization option and plumbs it through LSP server → project session. - Adds new telemetry event shapes (
projectInfo,performanceStats) to lsproto and sends them frominternal/project/session.go. - Adds a cross-platform system memory dependency and updates mocks/tests for the expanded
project.Clientinterface.
Reviewed changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/testutil/projecttestutil/clientmock_generated.go | Updates generated client mock to support SendTelemetry. |
| internal/project/session.go | Implements periodic performance telemetry and one-time project info telemetry; adds telemetry option and session start time. |
| internal/project/extendedconfigcache_test.go | Updates test client to satisfy new project.Client interface (SendTelemetry). |
| internal/project/client.go | Extends project.Client with SendTelemetry. |
| internal/lsp/server.go | Implements SendTelemetry on the server and wires enableTelemetry init option into session options and panic telemetry gating. |
| internal/lsp/lsproto/lsp_generated.go | Adds new telemetry event types/unions and enableTelemetry initialization option to generated protocol types. |
| internal/lsp/lsproto/_generate/generate.mts | Updates generator model with new telemetry events and validates telemetry event measurement/property shapes. |
| go.mod | Adds github.com/mackerelio/go-osstat for system memory metrics. |
| _extension/src/client.ts | Enables telemetry in initialization options (currently hard-coded true). |
| configFileName := "other" | ||
| if project.Kind == KindConfigured { | ||
| baseName := tspath.GetBaseFileName(project.configFileName) | ||
| if baseName == "tsconfig.json" || baseName == "jsconfig.json" { |
There was a problem hiding this comment.
Does this do the right thing for a solution-style project? Do we need to update this for strings.HasPrefix/HasSuffix?
There was a problem hiding this comment.
Surprisingly, Strada also had this problem. I could change this if you want.
There was a problem hiding this comment.
For reference:
export function getBaseConfigFileName(configFilePath: NormalizedPath): "tsconfig.json" | "jsconfig.json" | undefined {
const base = getBaseFileName(configFilePath);
return base === "tsconfig.json" || base === "jsconfig.json" ? base : undefined;
}| measurements.AutoImportProjectExportCount += float64(b.ExportCount) | ||
| measurements.AutoImportProjectFileCount += float64(b.FileCount) | ||
| } | ||
| for _, b := range autoImportStats.NodeModulesBuckets { |
There was a problem hiding this comment.
Maybe the one thing to add is an indication of whether any node_modules directory was scraped with no package.json filter; this is reported in the cache stats logging later in the file like this:
if bucket.DependencyNames != nil {
s.logger.Logf("\t\t\tCollected packages: %d", bucket.DependencyNames.Len())
} else {
s.logger.Logf("\t\t\tCollected packages: all, due to no package.json!")
}Otherwise, this all looks good to me.
There was a problem hiding this comment.
Added AutoImportNodeModulesUnfilteredBucketCount.
30638b8 to
fb9bfb2
Compare
This adds events to:
I added an initialization option that toggles telemetry wholesale; the client is already supposed to ignore it if it doesn't care, but best to not enable it when not needed. Of course, as per usual, telemetry is managed by VS Code and can be controlled like any other extension (and it's all just stats anyway). So the toggle is just for efficiency / testing reasons.
The goal of is is so we can gauge how much we are impacting memory usage. I want to start tweaking
GOGCandGOMEMLIMITbut would like to be able to see that it's doing anything.This introduces a new dep in order to get cross-platform memory info in pure Go.