Repository navigation
Releases
v0.1.3
0.1.3 — the interface speaks English too
Everything the extension shows — command titles, setting descriptions, the status
bar hint, the details panel, the Markdown report, the diagnostics output — now
follows VS Code's display language.
Chinese remains the authored language, so a Chinese VS Code looks exactly as
before; every other display language gets English. Nothing about the numbers
changed in this release: 0.1.3 is the 0.1.2 accounting with a bilingual UI.
Added
- English UI. 85 runtime strings and 24 manifest strings are translated.
Messages are authored in Chinese, so the Chinese string is the key and
l10n/bundle.l10n.en.jsonholds the English text. There is deliberately no
bundle.l10n.zh-cn.json: the host resolves an untranslated key to the authored
text, so a Chinese bundle could only ever be an identity map that silently rots.
Command titles and setting descriptions usepackage.nls.json(English, the
default) pluspackage.nls.zh-cn.json, the same two-file shape VS Code's own
built-in extensions ship.src/core/l10n.jswrapsvscode.l10n.tand falls back to in-place{0}
substitution when the host API is absent, so nothing throws on an older VS
Code and the headless test suites keep working.- The details QuickPick dispatches on codicon prefixes rather than on item
text, so a translated label can never break the command wiring.
Fixed
Switch scopeclaimed "no models configured yet" whenever
copilotOtelUsage.gatewayModelswas empty, even though host evidence alone
(server.addressin the records) can drive a correct grouping. It now needs
bothgatewayModelsandgatewayHoststo be empty before it hints.
Tests
- New
test/l10n.test.js(24 assertions) fails the build on at("…")call with
no English translation, an entry nothing uses, a translation that adds, drops
or renumbers a{0}placeholder, a translation left identical to its key, Han
characters surviving into the English text, or a stray
bundle.l10n.zh-cn.json.test/run-all.jsnow runs five suites.
Install
code --install-extension copilot-otel-usage-0.1.3.vsixThen reload the window. Coming from 0.1.1 or earlier, also run
Copilot Token Usage: Reset today and Copilot Token Usage: Re-scan data source
— those versions double-billed every call, and the stored totals keep showing it
until you reset.
Full changelog: CHANGELOG.md
v0.1.2
What changed
Fixed — one API call was being billed twice
Copilot Chat writes two records per model call: a
gen_ai.client.inference.operation.details record, and a second record with no
event.name at all. They share gen_ai.response.id but not a span, and only
one of the two carries gen_ai.usage.cache_read.input_tokens. The span-based
de-duplication id therefore never paired them, so every call was counted at its
full prompt size twice over.
Measured over one live export file (57.9 MB):
| Fact | Count |
|---|---|
| usage records | 1,800 |
distinct gen_ai.response.id |
923 |
| ids that repeat | 837 |
| …with byte-identical token counts | 817 |
…with a different cache_read value |
827 |
Records are now paired by gen_ai.response.id and merged per field with a
maximum, never a sum: the two records are two views of one response, so summing
re-bills the whole prompt while the max keeps it counted once and still picks up
the cache figure that only one side has. On the same day of real traffic the
figure went from 29.8M → 2.97M.
Added — per-route split: your endpoint vs Copilot's own models
The split is driven by the server.address each record carries — the host that
actually answered the request — with copilotOtelUsage.gatewayModels as a
name-based net for the paired record that omits the host. It works with no
configuration at all: a host that is not GitHub's own is treated as yours.
The short model name is deliberately not used as a discriminator:
gen_ai.provider.name is github for both routes, and deepseek-flash is a
substring of deepseek-v4-flash-ascend1.
copilotOtelUsage.statusBarScope(all/gateway/internal), switchable
without opening settings via切换统计范围. When a scope hides a route that has
traffic, the status bar appends↑ <amount>so a number is never silently partial.- Details panel and Markdown report gained a
按链路section above按模型. copilotOtelUsage.showGroupsturns the section off.- The
costformat intentionally ignores the scope: pricing rules match by model
name, so restricting the scope would produce a misleading estimate.
Also in 0.1.1 (included here)
- The total no longer counts cache-read tokens: the wire format reports cache
reads insideinput, and they were being added tooutputas if fresh. The
total is now(input − cached) + output— billable tokens, the same rule
gateways use. - Removed a dead
resourceSpansfan-out in the OTel reader: the live file
contains 2,234 flat log records and 6,474 metric envelopes, but zero
resourceSpans. - Fixed a "no-id fingerprint" de-dupe path that stored an object and compared it
withnow - seenAt— which isNaN, so it never matched anything. - Added
.vscodeignore: the packaged vsix carries only the runtime.
Install
code --install-extension copilot-otel-usage-0.1.2.vsixsha256: 8C90932F5E7763971BC123B9F39AEB0A0AEA0C101C2233A4BDB800246C1BB63E
Upgrading from 0.1.1 or 0.1.0? The stored state still holds the pre-fix
totals. After installing: reload the window → run
Copilot Token Usage: 重置今日统计→ run重新扫描数据源.
Verification
4/4 suites pass: parser 38 assertions, otel 40, smoke 19, activation harness 15
(the last one drives the real cycleScope command and asserts the status bar
text at all three scopes).
v0.1.1
Version 0.1.1 fixed the token total so it no longer counts cache-read tokens (the wire format reports them inside input).
0.1.2 supersedes this release and also fixes a double-counted report per call, plus adds the per-route split. Install that one instead: https://github.com/Albert-code-1114/vscode-copilot-otel-usage/releases/tag/v0.1.2
Copilot Token Usage 0.1.0
First release.
Status-bar readout of this request / today's total tokens for GitHub
Copilot Chat, including BYOK and custom-endpoint models. It reads the
OpenTelemetry JSON Lines file Copilot Chat can already export itself --
no proxy to run, nothing patched.
Added
- Status bar readout in four formats (
lastDay,last,day,cost). otel-filedata source reading thegithub.copilot.chat.otel.*export:- understands all three record shapes that can appear -- OTel log records
(what the file exporter actually writes), OTLP span envelopes, and raw
SDK spans - incremental reads: only new bytes are parsed
- per-call de-duplication id persisted across window reloads, so replaying
the file from byte 0 never double-counts - events from other local dates are discarded, not folded into today
- understands all three record shapes that can appear -- OTel log records
- Details panel: today's summary, per-model split, last 30 requests.
- Markdown report export.
诊断数据源command: per-source connection state, lines read, and a verdict
explaining a zero.- Optional local price list and cost estimation.
- Model exclusion by substring (e.g. the small utility model Copilot uses to
title conversations). - Offline test suite -- 4 suites / 87 assertions, no VS Code required.
Install
Download copilot-otel-usage-0.1.0.vsix below, then:
code --install-extension copilot-otel-usage-0.1.0.vsix
Then point it at the export file -- see the Install section of the README.
Notes
- Reads only the officially exported surface. It does not patch, instrument,
or modify VS Code or the Copilot extension. - Command titles and UI text are Chinese in this release.