Repository navigation
gateway: log one usage line per model call (model, tokens, hashed key id; no text) - #31
Merged
Merged
Conversation
|
✅ Deterministic PR hygiene checks passed. |
… id; no text) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
vadymhimself
force-pushed
the
gauge/usage-log
branch
from
November 15, 2026 04:37
6cd770b to
b8acc2a
Compare
Collaborator
Author
|
independent-qa (Mars): GREEN at (Reviewed at 6cd770b. This head is a rebase onto main, which now has #30. All 10 of this PR's file blobs are identical to 6cd770b.) What I checked:
Before merge:
Not blocking:
A new push voids this GREEN. |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collaborator
Author
|
independent-qa (Mars): GREEN at The commit changes only
No product file changed, so my review stands. Merge once CI is green at this sha. A new push voids this GREEN. |
vadymhimself
merged commit Nov 15, 2026
8ca6f61
into
release/2.65.0-vadymhimself.15
60 of 62 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The gateway logs no model, tokens or caller per call, so per-key usage (for example the share of calls and tokens on each model) can't be read from the process log. The fork already holds that on its own final request record and usage ledger, but only in the gateway's memory and local disk.
What
src/lib/usage-line-log.ts(new): one line per finished request:[usage] status=<http> provider="<id>" model="<id>" in=<n> out=<n> cached=<n> key=<8-hex> ms=<n>.keyis the first 8 hex of sha256 of the configured key's record id, never the secret. Environment or loopback admission has no id and logs-.-.OPENCODEX_AGENTRADAR=1, the same condition as the[ar-acct]line, so a self-hosted gateway gains no new output. It never throws.src/server/request-log.ts: one call inaddRequestLog, the single sink every finished request row passes through, on the same record the usage ledger persists. Local refusals (413, 429) also log, with counts-.structure/transports/byte-accounting.md: documents the line.release-version-sources sync(all 4 sources).Tests
tests/lib/call-usage-line-log.test.ts(new, 8): fields and format; prompt text, secret and authorization header never appear; ids with newlines or 200 characters stay on one bounded line; account suffix dropped; off without AgentRadar mode; missing counts log-. Driven from the fork's own request record, so no provider payload is imitated.Eval added/updated: a finished request through the request log writes one usage line with model, token counts and a hashed key id, and no prompt text or secret appears in it.
🤖 Generated with Claude Code