Repository navigation
Description
Describe the bug
The GitHub Copilot app exports OpenTelemetry traces and metrics when telemetry is set in a file-based managed-settings.json. Spans are exported as they end. Metrics are exported only on a timer, every 60 seconds. When you quit the app, it does not export the metrics recorded since the last timer export.
If you quit the app before its first timer export, none of that session's metrics are exported, but its spans are. Backends that read the metrics (token usage, github.copilot.code.lines_added, github.copilot.tool.call.count) undercount usage in the app, and short sessions are missing completely.
Copilot CLI and VS Code export their metrics when they exit:
- Copilot CLI 1.0.119 sent its metrics once, at exit.
- VS Code 1.149 with the Copilot harness (runtime 1.0.116) sent metrics on its timer, and again when VS Code exited.
We saw this in two app sessions on the same machine, with the same managed settings and the same collector:
| Session | How long the app ran | Spans exported | Metric exports |
|---|---|---|---|
| 1 | Closed about 1 minute after the reply | Yes | None |
| 2 | About 3.5 minutes, then quit from the tray icon | Yes | 2, 60 seconds apart, the first about 2 minutes after the session started. None at quit |
The metrics from session 2 had the right totals. Its cumulative token counters matched the token usage on the chat spans. So the metrics themselves are fine; only the final export at quit is missing.
Affected version
GitHub Copilot app 1.5.0 on Windows. Its runtime reports service.version 1.0.115-7.
Steps to reproduce the behavior
-
Run a local OpenTelemetry Collector (for example
otelcol-contrib) that logs what it receives:receivers: otlp: protocols: http: endpoint: 127.0.0.1:4318 exporters: debug: {} service: pipelines: traces: { receivers: [otlp], exporters: [debug] } metrics: { receivers: [otlp], exporters: [debug] }
-
Create
C:\Program Files\GitHubCopilot\managed-settings.json:{ "telemetry": { "enabled": true, "endpoint": "http://127.0.0.1:4318", "protocol": "http/protobuf", "captureContent": false } } -
Start the app. Send a short prompt that edits a file, such as
Create a.txt with three lines about OpenTelemetry, and wait for the reply. -
Within 60 seconds of the reply, quit the app from the tray icon (Quit).
-
The collector logs the spans (
invoke_agent,chat,execute_tool) but no metrics. -
Repeat, but leave the app open for 3 minutes before you quit. Metrics now arrive every 60 seconds, but nothing arrives when you quit.
Expected behavior
When the app quits, it shuts down its meter provider and exports the final metric values, as Copilot CLI does at exit.
Additional context
- Windows 11 (10.0.26200), x86_64. No
OTEL_*orCOPILOT_OTEL_*environment variables were set, and telemetry came only from the managed settings file. - The collector can't work around this, because the final values never leave the app. Each runtime process has its own random
service.instance.idand cumulative counters, so a later export can't recover them either. For now, we derive our metrics from spans instead. - This is not a duplicate of Desktop app: enterprise managed settings ignored for telemetry, and exported spans omit GitHub repo/org/branch attributes #4782. That issue is about the app ignoring managed telemetry settings. In our tests, the app version above applies file-based managed telemetry: spans and metrics reach the collector with the configured resource attributes. This issue is only about metrics being lost when the app quits.
Activity