Repository navigation
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).