Skip to content

backport: highlight matched conditional multipliers in logs (#6561) - #1

Merged
kk66615 merged 1 commit into
patch/rc24-billing-fixesfrom
backport/request-rules-trace
Aug 18, 2026
Merged

kk66615 merged 1 commit into
patch/rc24-billing-fixesfrom
backport/request-rules-trace

Conversation

@kk66615

@kk66615 kk66615 commented Aug 18, 2026

Copy link
Copy Markdown
Owner

从上游 QuantumNous/new-api main 分支 cherry-pick 提交 `4cf9107f`(feat(billing): highlight matched conditional multipliers in logs, QuantumNous#6561)。

动机

rc.24 的 `TraceResult` 没有 `request_rules` 字段,条件乘数(如按时段的 ×2)不会把命中状态写进 consume log,日志详情页因此永远显示不出「已命中」。计费本身正确,只是缺少可视化。

改动

  • `pkg/billingexpr`:编译期给三元乘数埋点,运行期记录 `RequestRuleTrace{cond, multiplier, matched}`
  • `service/log_info_generate.go`:命中列表非空时写入 `other["request_rules"]`
  • 前端 `pricing` / `usage-logs`:优先按 `request_rules` 渲染,解析表达式作为回退

验证

cherry-pick 零冲突。本地按 ci.yml 步骤执行:

  • `go vet ./...`(root + relaykit)exit 0
  • `go build ./...`(root + relaykit)exit 0
  • `make test` exit 0,39 个包全部 ok,含 `pkg/billingexpr`
  • `bun run typecheck` exit 0
  • `bun test` 124 pass / 9 fail / 6 errors —— 与本分支基线逐条一致,失败全在 `features/keys`、`features/channels`(`node:test` 的 describe 嵌套在 Bun 1.3.14 下不支持),与本改动无关

工具版本:go1.26.5、bun 1.3.14(与 CI 固定版本一致)

…ntumNous#6561)

* feat(billing): highlight matched conditional multipliers in usage logs

* fix(billing): make request rule tracing stable and type-safe
@kk66615
kk66615 merged commit 0b6de36 into patch/rc24-billing-fixes Aug 18, 2026
2 of 3 checks passed
@kk66615
kk66615 deleted the backport/request-rules-trace branch August 18, 2026 03:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants