-
Notifications
You must be signed in to change notification settings - Fork 972
init token statistics plugin #3280
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
undertaker86001 seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
ff1eeaa to
e719cad
Compare
| normalizedType := strings.TrimSpace(strings.ToLower(model)) | ||
|
|
||
| // 处理别名(兼容不同命名习惯) | ||
| switch normalizedType { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里的模型名字会这么规范吗?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
是需要处理如果model比如用户输入错误的model 要兼容对吗?是否需要加入模糊匹配?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
问题是这里能识别准吗?是否有别的办法?
| defaultConfigDisable: false | ||
| ``` | ||
|
|
||
| ### 4.6.3 功能验证 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
为什么这里是 4.6.3?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
本地的一些笔记,写readme的时候不想重复写把本地笔记拷贝了,会更正的
| go run ./ | ||
| ``` | ||
|
|
||
| 跟着官网https://higress.cn/zh-cn/blog/e2e-debug/测试插件 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个链接不对
|
|
||
| 注意:插件在真实运行时依赖 proxy-wasm hostcalls(例如定义/记录指标、获取 HTTP header 等)。直接在本地通过 `go run` 或 `go test` 运行会遇到 hostcall 不可用的问题(��触发 panic)。为方便本地开发,本仓库做了以下改进: | ||
|
|
||
| - 在 `main.go` 中,将指标抽象为 `metricCounter` 并提供 `noopCounter`,在非 Wasm 环境下跳过调用真实 hostcalls,避免 panic。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个地方用测试的 VM 也不行吗?
| 如有问题,请在仓库中创建 issue,或直接在 PR 中指明你遇到的问题与预期行为。 | ||
|
|
||
| 创建WasmPlugin资源配置: | ||
| 确保插件执行在 AI-Cache 插件之后(通过priority配置,数值越大执行越晚); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这部分最好放在配置那边,也最好注明推荐的执行阶段和优先级。现在太不显眼了
| @@ -0,0 +1,180 @@ | |||
| # Token Statistics Plugin | |||
|
|
|||
| 该目录实现了 Higress 的 `token-statistics` wasm 插件,用于从各类 AI 服务响应中提取 token 使用量并导出到日志/指标,以便进行成本统计与监控。 | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个插件与 ai-statistics 插件的关系是什么呢,是否可以同时使用?
…ken-statistics Key improvements: - Restore full Prometheus metrics verification logic - Increase retry count from 10 to 15 times (45s total timeout) - Increase retry interval from 2s to 3s for better stability - Add detailed error logging and troubleshooting hints - Implement graceful degradation when Prometheus unavailable - Restore complete exporter and dimensions configuration Metrics verified: - input_tokens_total - output_tokens_total - total_tokens_total - Aggregate queries across all models
Ⅰ. Describe what this PR did
fix #3214
Ⅱ. Does this pull request fix one issue?
fix #3214
Ⅲ. Why don't you add test cases (unit test/integration test)?
Ⅳ. Describe how to verify it
run e2e for verify
Ⅴ. Special notes for reviews
Ⅵ. AI Coding Tool Usage Checklist (if applicable)
no ai coding tools
Please check all applicable items:
design/directory in the plugin folderdesign/directorywill add design directory later
AI Coding Prompts (for regular updates)
AI Coding Summary