Skip to content

Add telemetry correlation headers to dev tunnel service requests - #340787

Merged
Connor Peet (connor4312) merged 4 commits into
mainfrom
connor/tunnel-service-correlation
Oct 9, 2026
Merged

Connor Peet (connor4312) merged 4 commits into
mainfrom
connor/tunnel-service-correlation

Conversation

@connor4312

@connor4312 Connor Peet (connor4312) commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

Summary

Correlate Dev Tunnels management requests and relay handshakes with VS Code telemetry using the SDK support from microsoft/dev-tunnels#685.

Companion Remote Tunnels extension/SDK changes: microsoft/vscode-remote-tunnels#807.

  • Upgrade the TypeScript Dev Tunnels SDKs to 1.3.61 and pin the Rust SDK to the custom-header implementation.
  • Read session IDs directly from injected ITelemetryService in the browser/shared-process clients and CLI process coordinator.
  • Attach X-Tunnels-VSCode-Session-Id, X-Tunnels-VSCode-Client-Operation-Id, and a fresh X-Tunnels-VSCode-Client-Request-Id for management requests and supported relay handshakes.
  • Record operation IDs in tunnelServiceOperation and correlate CLI hosting with existing remoteTunnel.connected telemetry.
  • Use tunnelSessionId for explicit telemetry correlation so the reserved common sessionID property is not shadowed.
  • Pass host correlation into the CLI through environment variables, preserving non-UUID telemetry session IDs verbatim. Standalone commands use process-local session IDs.
  • Avoid attributing an attachment to an already-running tunnel's service requests to the new attaching process.
  • Keep correlation IDs out of CLI debug logs; send them only in service headers.
  • Retain correlation IDs for transient CLI invocations without emitting misleading host-operation telemetry for status, login, or local service-management commands.

Browser WebSocket APIs cannot attach custom handshake headers; browser management requests still include them.

Validation

Rebased onto main before publishing.

  • npm run build-fast -- --client-only — passed.

  • npm run typecheck-client — passed after rebase.

  • Focused unit tests — 93 passed after rebase:

    ./scripts/test.sh --reporter dot \
      --run src/vs/platform/remoteTunnel/test/common/tunnelServiceHeaders.test.ts \
      --run src/vs/platform/remoteTunnel/test/node/tunnelProcessCoordinator.test.ts \
      --run src/vs/platform/remoteTunnel/test/node/remoteTunnelService.test.ts \
      --run src/vs/platform/agentHost/test/node/tunnelAgentHostService.test.ts \
      --run src/vs/platform/agentHost/test/common/tunnelAgentHostConnector.test.ts \
      --run src/vs/sessions/contrib/providers/remoteAgentHost/test/browser/browserTunnelAgentHostService.test.ts \
      --run src/vs/sessions/contrib/providers/remoteAgentHost/test/electron-browser/tunnelAgentHostServiceImpl.test.ts
  • cargo test --locked --manifest-path cli/Cargo.toml tunnels::dev_tunnels::test — 5 passed.

  • Changed-TypeScript ESLint — passed before commit:

    git diff --name-only --diff-filter=ACM -z -- '*.ts' | xargs -0 npm run eslint -- src/vs/platform/remoteTunnel/common/tunnelServiceHeaders.ts src/vs/platform/remoteTunnel/test/common/tunnelServiceHeaders.test.ts
  • npm run valid-layers-check — passed during implementation.

  • Scoped telemetry extraction including the actual telemetry common-property declarations — passed after fixing the CI metadata collision; verified tunnelSessionId does not shadow sessionID, event classifications, and numeric/boolean measurement flags.

  • CI-fix and review-feedback regression tests — 32 passed:

    ./scripts/test.sh --reporter dot \
      --run src/vs/platform/remoteTunnel/test/common/tunnelServiceHeaders.test.ts \
      --run src/vs/platform/remoteTunnel/test/node/tunnelProcessCoordinator.test.ts \
      --run src/vs/platform/remoteTunnel/test/node/remoteTunnelService.test.ts \
      --run src/vs/platform/agentHost/test/node/tunnelAgentHostService.test.ts
  • Repository pre-commit hygiene — passed.

Live Dev Tunnels service/backend ingestion and full integration/smoke suites were not run.

Use tunnel services' injected telemetry sessions, record operation correlation, and generate fresh request IDs for management requests and relay handshakes. Pass host correlation into the CLI and preserve non-UUID session IDs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 9, 2026 19:11
@connor4312
Connor Peet (connor4312) enabled auto-merge (squash) October 9, 2026 19:11
Use tunnelSessionId for explicit tunnel correlation without shadowing the reserved common sessionID property. Preserve request header values and operation IDs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Send session and operation IDs only in tunnel service headers, removing the debug log flagged by CodeQL.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

3 open findings
What changed in this PR

Adds telemetry correlation for Dev Tunnels management requests and (where supported) relay handshakes, enabling VS Code telemetry session/operation/request IDs to flow through web, desktop, and CLI tunnel interactions.

Changes:

  • Introduces shared tunnel correlation/helpers (createTunnelServiceCorrelation, tunnelServiceHeaders) and wires them into browser, agent host, remote tunnel, and CLI flows.
  • Extends the tunnel coordinator + telemetry events to carry correlation (session/operation IDs) into CLI invocations and remoteTunnel.connected.
  • Updates Dev Tunnels SDK dependencies (TS to 1.3.61, Rust tunnels git rev) and adds focused unit tests.
File Description
src/​vs/​sessions/​contrib/​providers/​remoteAgentHost/​test/​browser/​browserTunnelAgentHostService.test.ts Updates browser tests to validate management client receives additional request headers.
src/​vs/​sessions/​contrib/​providers/​remoteAgentHost/​browser/​webTunnelAgentHostService.contribution.ts Injects ITelemetryService into browser tunnel agent host service selection.
src/​vs/​sessions/​contrib/​providers/​remoteAgentHost/​browser/​devTunnelsWebLoader.ts Extends web management client interface to accept additional request headers.
src/​vs/​sessions/​contrib/​providers/​remoteAgentHost/​browser/​browserTunnelAgentHostService.ts Attaches correlation headers to browser management requests and relay creation path.
src/​vs/​platform/​remoteTunnel/​test/​node/​tunnelProcessCoordinator.test.ts Adds test coverage ensuring correlation env vars are passed to all CLI invocations.
src/​vs/​platform/​remoteTunnel/​test/​node/​remoteTunnelService.test.ts Updates tests to validate correlation is plumbed into remoteTunnel.connected telemetry.
src/​vs/​platform/​remoteTunnel/​test/​common/​tunnelServiceHeaders.test.ts New unit tests for header correlation + per-request request-id refresh behavior.
src/​vs/​platform/​remoteTunnel/​node/​tunnelProcessCoordinator.ts Passes correlation into CLI env and machine-status events; suppresses correlation on attach.
src/​vs/​platform/​remoteTunnel/​node/​remoteTunnelService.ts Logs correlation into remoteTunnel.connected when available; updates telemetry classifications.
src/​vs/​platform/​remoteTunnel/​common/​tunnelServiceHeaders.ts New shared helper for creating correlation IDs and generating headers (fresh request ID per copy).
src/​vs/​platform/​agentHost/​test/​node/​tunnelAgentHostService.test.ts Adds correlation-focused tests and updates construction to inject telemetry service.
src/​vs/​platform/​agentHost/​node/​tunnelAgentHostService.ts Adds correlation header injection to management client creation for list/connect/delete.
package.json Bumps Dev Tunnels TypeScript SDK packages to ^1.3.61.
cli/​src/​tunnels/​dev_tunnels.rs Adds correlation header injection based on env vars (with validation) + Rust tests.
cli/​Cargo.toml Pins Rust tunnels dependency to a newer git revision supporting custom headers.
cli/​CONTRIBUTING.md Documents tunnel request correlation behavior and env vars for CLI.

🧠 Review effort: Lite


💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/vs/platform/remoteTunnel/node/tunnelProcessCoordinator.ts
Comment thread cli/src/tunnels/dev_tunnels.rs Outdated
Comment thread src/vs/platform/remoteTunnel/common/tunnelServiceHeaders.ts Outdated
Keep correlation IDs for every CLI invocation but emit host-operation telemetry only for actual host launches. Reuse a single Rust fallback header and share the narrow operation type across telemetry declarations.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@connor4312
Connor Peet (connor4312) merged commit e23b74e into main Oct 9, 2026
56 of 57 checks passed
@connor4312
Connor Peet (connor4312) deleted the connor/tunnel-service-correlation branch October 9, 2026 20:47
@vs-code-engineering vs-code-engineering Bot added this to the 1.142.0 milestone Oct 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants