Skip to content

Enterprise OTel managed-settings policy#323171

Closed
zhichli wants to merge 1 commit into
mainfrom
zhichli/otelpolicy
Closed

Enterprise OTel managed-settings policy#323171
zhichli wants to merge 1 commit into
mainfrom
zhichli/otelpolicy

Conversation

@zhichli

@zhichli zhichli commented Jun 26, 2026

Copy link
Copy Markdown
Member

Adds enterprise managed-settings policies for OpenTelemetry, covering both VS Code OTel surfaces without introducing a new settings namespace.

What

  • chat.agentHost.otel.* settings own the OTel policies; the Copilot extension's github.copilot.chat.otel.* settings reference them via policyReference (same pattern as Claude3PIntegration).
  • Managed-settings keys, aligned with the CLI/control-plane telemetry schema: telemetry.enabled, telemetry.endpoint, telemetry.protocol, telemetry.captureContent, telemetry.lockCaptureContent.
  • Enterprise policy values take precedence over env vars and user settings. A managed endpoint/protocol suppresses file-exporter diversion so telemetry can't be redirected to a local file.

Notes

  • Server delivery of the telemetry block is tracked separately (github/agent-control-plane#658, github/copilot-agent-runtime#10735); until that ships, validate via the mock policy server or native MDM.
  • headers / resourceAttributes / serviceName from the shared schema are not enforced in VS Code yet (follow-up).

Test

  • Unit/integration: managed-settings adapter, OTel config precedence, agent-host env fanout, policy export catalog.

Copilot AI review requested due to automatic review settings June 26, 2026 17:07

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.

Pull request overview

Adds enterprise managed-settings policy support for Copilot OpenTelemetry across both the VS Code “agent host” surface (chat.agentHost.otel.*) and the Copilot extension surface (github.copilot.chat.otel.*), using a shared telemetry.* managed-settings key set and policyReference wiring so one policy governs both settings trees.

Changes:

  • Extend managed-settings ingestion to accept and flatten telemetry.* keys (including nested telemetry.dbSpanExporter.enabled).
  • Register new configuration policies for chat.agentHost.otel.* and reference them from Copilot extension settings.
  • Update OTel config/env precedence logic and add tests/docs to reflect enterprise policy priority.
Show a summary per file
File Description
src/vs/workbench/services/accounts/test/browser/managedSettings.test.ts Adds coverage ensuring telemetry.* is flattened into dot-path managed settings.
src/vs/workbench/services/accounts/browser/managedSettings.ts Extends server response typing to include a telemetry block.
src/vs/platform/policy/common/copilotManagedSettings.ts Adds managed-settings key constants for telemetry.*.
src/vs/platform/agentHost/test/node/otel/agentHostOTelService.integrationTest.ts Adds integration tests for policy-vs-env precedence in agent-host env construction.
src/vs/platform/agentHost/OTEL.md Updates docs for settings→env translation precedence including enterprise policy overrides.
src/vs/platform/agentHost/node/nodeAgentHostStarter.ts Plumbs configuration policyValue into agent-host OTel env construction.
src/vs/platform/agentHost/electron-main/electronAgentHostStarter.ts Same policy plumbing for the Electron main starter.
src/vs/platform/agentHost/common/agentService.ts Implements policy override/clearing behavior in buildAgentHostOTelEnv.
src/vs/platform/agentHost/common/agentHostStarter.config.contribution.ts Registers new enterprise policies and maps managed-settings telemetry.* to OTel settings.
extensions/copilot/src/platform/otel/common/test/otelConfig.spec.ts Adds tests asserting policy precedence over env/settings.
extensions/copilot/src/platform/otel/common/otelConfig.ts Implements policy-aware precedence in resolveOTelConfig.
extensions/copilot/src/extension/extension/vscode-node/services.ts Attempts to feed policy values into OTel config resolution from extension settings.
extensions/copilot/package.json Adds policyReference entries for Copilot extension OTel settings.
extensions/copilot/docs/monitoring/agent_monitoring.md Documents enterprise managed-settings keys and updated precedence rules.
extensions/copilot/docs/monitoring/agent_monitoring_arch.md Updates architecture doc precedence and enabledVia semantics.
build/lib/policies/policyData.jsonc Updates generated policy catalog to include the new Copilot OTel policies.

Review details

  • Files reviewed: 16/16 changed files
  • Comments generated: 7
  • Review effort level: Low

Comment on lines 291 to +307
@@ -298,6 +299,12 @@ export function registerServices(builder: IInstantiationServiceBuilder, extensio
settingMaxAttributeSizeChars: otelSettings.get<number>('maxAttributeSizeChars'),
settingOutfile: otelSettings.get<string>('outfile') || undefined,
settingDbSpanExporter: otelSettings.get<boolean>('dbSpanExporter.enabled'),
policyEnabled: policyValue<boolean>('enabled'),
policyExporterType: policyValue<'otlp-grpc' | 'otlp-http' | 'console' | 'file'>('exporterType'),
policyOtlpEndpoint: policyValue<string>('otlpEndpoint'),
policyCaptureContent: policyValue<boolean>('captureContent'),
policyOutfile: policyValue<string>('outfile'),
policyDbSpanExporter: policyValue<boolean>('dbSpanExporter.enabled'),
const dbSpanExporter = input.policyDbSpanExporter ?? input.settingDbSpanExporter ?? false;

// Determine if enabled: env > setting > dbSpanExporter > default(false)
const policyMandatesOtlp = input.policyOtlpEndpoint !== undefined || input.policyExporterType !== undefined;
Comment on lines +385 to +388
if (policySettings.exporterType !== undefined) {
setPolicy(AgentHostOTelEnvVars.ExporterType, policySettings.exporterType);
setPolicy(AgentHostOTelEnvVars.FilePath, '');
}
Comment on lines +146 to +149
{
"key": "chat.agentHost.otel.enabled",
"name": "CopilotOtelEnabled",
"category": "InteractiveSession",
"policyReference": {
"name": "CopilotOtelEnabled"
},
"markdownDescription": "Enable OpenTelemetry trace/metric/log emission for Copilot Chat operations. Configurable in user settings only. Env var `COPILOT_OTEL_ENABLED` takes precedence. Requires window reload.",
"policyReference": {
"name": "CopilotOtelEndpoint"
},
"markdownDescription": "OTLP collector endpoint URL for Copilot Chat OTel data. Configurable in user settings only. Env var `OTEL_EXPORTER_OTLP_ENDPOINT` takes precedence. Requires window reload.",
"policyReference": {
"name": "CopilotOtelCaptureContent"
},
"markdownDescription": "Capture input/output messages, system instructions, and tool definitions in OTel telemetry. **Contains potentially sensitive data.** Configurable in user settings only. Env var `COPILOT_OTEL_CAPTURE_CONTENT` takes precedence. Requires window reload.",
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants