Add telemetry to keep an eye on the number of network requests we're sending#4321
Merged
Add telemetry to keep an eye on the number of network requests we're sending#4321
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds telemetry instrumentation to track the number and latency of network requests made by the extension. It introduces a mandatory callSite property on FetchOptions to identify where each fetch request originates, fires a FetchTelemetryEvent after each fetch completion (success or failure), and subscribes to those events in the TelemetryService to send fetchTelemetry events — restricted to Insiders (pre-release) builds only.
Changes:
- Adds
callSiteas a required field onFetchOptions, aFetchTelemetryEventinterface, and anonDidCompleteFetchevent toIFetcherService, with the event emitted fromFetcherService.fetch()on both success and error paths. - Updates all existing
fetch()call sites across the codebase (30+ files) to include a descriptivecallSitestring, and adds aNO_FETCH_TELEMETRYsentinel to suppress telemetry on the telemetry service's own fetch calls. - Subscribes to the new event in
TelemetryService(Insiders only) to emitfetchTelemetrytelemetry events withcallSite,latencyMs, andstatusCode.
Reviewed changes
Copilot reviewed 34 out of 34 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/platform/networking/common/fetcherService.ts |
Adds callSite to FetchOptions, FetchTelemetryEvent interface, onDidCompleteFetch event to IFetcherService, NO_FETCH_TELEMETRY constant, and safeGetHostname helper |
src/platform/networking/vscode-node/fetcherServiceImpl.ts |
Fires onDidCompleteFetch from fetch() on success/error, with latency measurement |
src/platform/telemetry/vscode-node/telemetryServiceImpl.ts |
Subscribes to fetch telemetry events (Insiders only) and sends MSFT telemetry; uses NO_FETCH_TELEMETRY for its own fetch calls |
src/extension/extension/vscode-node/services.ts |
**Contains `if (true |
src/extension/completions-core/vscode-node/lib/src/networking.ts |
Adds callSite to CompletionsFetcher.fetch() and postRequest() |
src/platform/networking/common/networking.ts |
Adds dynamic callSite: network-request-${intent} |
src/platform/github/common/githubAPI.ts |
Adds callSite to GitHub REST, GraphQL, and sessions API calls |
src/platform/github/common/githubService.ts |
Adds callSite to GitHub status check |
src/platform/authentication/node/copilotTokenManager.ts |
Adds callSite to token fetch calls |
src/extension/byok/vscode-node/*.ts |
Adds callSite to BYOK/Ollama provider fetch calls |
src/extension/mcp/vscode-node/*.ts |
Adds callSite to NuGet, npm, PyPI, Docker registry calls |
src/extension/log/vscode-node/loggingActions.ts |
Adds callSite to diagnostics probe fetch calls |
src/extension/inlineEdits/vscode-node/components/nesFeedbackSubmitter.ts |
Adds callSite to NES feedback GitHub API calls |
src/extension/prompt/node/chatMLFetcher.ts |
Adds callSite to CAPI ping |
src/platform/snippy/common/snippyFetcher.ts |
Adds callSite to snippy match |
src/platform/nesFetch/node/completionsFetchServiceImpl.ts |
Adds callSite to NES completions |
src/platform/proxyModels/node/proxyModelsService.ts |
Adds callSite to proxy models |
src/platform/releaseNotes/vscode/releaseNotesServiceImpl.ts |
Adds callSite to release notes fetch |
src/platform/embeddings/common/embeddingsIndex.ts |
Adds callSite to embeddings cache fetches |
src/platform/endpoint/node/routerDecisionFetcher.ts |
Adds callSite to router decision |
src/extension/completions-core/vscode-node/lib/src/snippy/*.ts |
Adds callSite to snippy network and ping |
| Various test files | Updates mock IFetcherService implementations with onDidCompleteFetch and callSite in test fetch calls |
src/extension/completions-core/vscode-node/lib/src/networking.ts
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
amunger
reviewed
Mar 10, 2026
| protected async getFileContentWithToken(owner: string, repo: string, ref: string, path: string, token: string): Promise<string> { | ||
| const route = `repos/${owner}/${repo}/contents/${path}?ref=${encodeURIComponent(ref)}`; | ||
| const response = await makeGitHubAPIRequest(this._fetcherService, this._logService, this._telemetryService, this._capiClientService.dotcomAPIURL, route, 'GET', token, undefined); | ||
| const response = await makeGitHubAPIRequest(this._fetcherService, this._logService, this._telemetryService, this._capiClientService.dotcomAPIURL, route, 'GET', token, undefined, undefined, undefined, undefined, undefined, undefined, 'github-rest-get-file-content'); |
amunger
approved these changes
Mar 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of https://github.com/microsoft/vscode-internalbacklog/issues/7034