npx skills add ...
npx skills add microsoft/vscode --skill otel
OpenTelemetry guidance for VS Code agent experiences. Use when changing Agent Host telemetry, local Copilot Chat telemetry, provider-native spans or metrics, OTel settings and managed policy, trace persistence/export, or monitoring documentation.
npx skills add microsoft/vscode --skill otel
Start by identifying the execution surface. VS Code has separate OTel pipelines with different owners and configuration:
| Surface | Process and producer | Configuration | Authoritative VS Code document |
|---|---|---|---|
| Agent Host sessions (Copilot, Claude, Codex) | Provider-native telemetry routed by the Agent Host utility process | chat.agentHost.otel.* | src/vs/platform/agentHost/OTEL.md |
| Local Copilot Chat | Copilot Chat extension host and IOTelService | github.copilot.chat.otel.* | extensions/copilot/docs/monitoring/agent_monitoring.md |
Do not combine these pipelines or assume that a setting for one configures another.
Agent Host is the current execution architecture for Copilot, Claude, and Codex agent sessions. It owns routing, optional trace interception and SQLite persistence, resource normalization, and cross-provider trace context. Each provider owns its native instrumentation.
The extension-host Copilot CLI source remains as a fallback when Agent Host is unavailable and to support legacy-session migration. It is normally hidden when Agent Host is available and is not the current Agent Host architecture. Do not use it as a model for new work.
Local Copilot Chat remains a separate user-visible extension-host surface. Its foreground chat, LLM, tool, hook, metric, and event instrumentation continues to use IOTelService under extensions/copilot/src/platform/otel/.
Copilot's native OTel signal contract lives in github/copilot-agent-runtime, not in VS Code's TypeScript attribute constants. Before auditing or changing the integration:
@github/copilot-sdk and @github/copilot from the root package-lock.json.main only after confirming that the relevant files are unchanged from the bundled revision.The runtime's docs/developer-docs/monitor.md is exhaustive for native Copilot spans, attributes, span events, metrics, protocols, environment variables, content capture, TLS, and managed settings. Read it at the revision corresponding to the bundled package and link to that immutable revision in investigation or review evidence rather than copying its signal tables into VS Code documentation.
Shared transport and persistence live under:
Agent Host supports two routing modes:
Read src/vs/platform/agentHost/OTEL.md before changing either mode.
For extension-emitted attributes, use constants from extensions/copilot/src/platform/otel/common/genAiAttributes.ts. Those constants are not authoritative for provider-native Agent Host telemetry.
When changing Agent Host configuration:
common/agentHostStarter.config.contribution.ts.buildAgentHostOTelEnv() in common/agentService.ts.readAgentHostOTelEnv() or provider launch translation as applicable.src/vs/platform/agentHost/OTEL.md.policy-and-managed-settings skill for any enterprise control.When changing local Copilot Chat configuration:
extensions/copilot/package.json.resolveOTelConfig() in extensions/copilot/src/platform/otel/common/otelConfig.ts.agent_monitoring.md.Never add a new VS Code setting merely to mirror a new runtime-owned managed setting. Follow the runtime-managed-settings ownership rules.
For Agent Host provider-native signals:
For host-produced spans:
common/otel/agentHostOTelService.ts or shared platform constants.service.namespace=vscode.agent-host while retaining distinct provider service names.traceparent and tracestate through the provider's supported boundary.For local Copilot Chat signals:
IOTelService, not directly on an OTel SDK from consumers.gen_ai.* keys when they exist.github.copilot.*; do not add new copilot_chat.* keys.truncateForOTel with the configured maximum.Do not claim one protocol matrix for every Agent Host provider:
otel.* overrides.Check the provider launch code and bundled provider version before documenting support.
src/vs/platform/agentHost/OTEL.md.extensions/copilot/docs/monitoring/agent_monitoring.md.Choose the smallest checks that cover the change.
Agent Host examples:
Local Copilot Chat examples, from extensions/copilot/:
For documentation-only changes, verify:
main matches the package bundled by VS Code.src/vs/platform/otel/
├── common/ # normalized span data and shared attributes
└── node/
├── otlp/ # receiver, decoder, outbound forwarders
└── sqlite/ # persistent span storeextensions/copilot/src/platform/otel/
├── common/ # IOTelService, config, attributes, events, metrics
└── node/ # SDK implementation and exporters
extensions/copilot/src/extension/
├── prompt/node/chatMLFetcher.ts # chat spans
├── intents/node/toolCallingLoop.ts # invoke_agent spans
├── tools/vscode-node/toolsService.ts # execute_tool spans
├── chat/vscode-node/chatHookService.ts # execute_hook spans
├── byok/vscode-node/ # BYOK chat spans
└── trajectory/vscode-node/ # Agent Debug Log conversion./scripts/test.sh --grep "AgentHostOTel\|agent host.*OTel"
./scripts/test-integration.sh --run src/vs/platform/agentHost/test/node/otel/agentHostOTelService.integrationTest.tsnpx tsc --noEmit --project tsconfig.json
npm test -- --grep "OTel"