Skip to content

feat(ai-proxy): support token usage statistics#6609

Merged
sfwn merged 2 commits intoerda-project:masterfrom
sfwn:feat/ai-proxy-token-usage
Oct 14, 2025
Merged

feat(ai-proxy): support token usage statistics#6609
sfwn merged 2 commits intoerda-project:masterfrom
sfwn:feat/ai-proxy-token-usage

Conversation

@sfwn
Copy link
Copy Markdown
Member

@sfwn sfwn commented Oct 13, 2025

What this PR does / why we need it:

AI-Proxy support token usage statistics.

Which issue(s) this PR fixes:

ChangeLog

Language Changelog
🇺🇸 English AI-Proxy support token usage statistics
🇨🇳 中文 AI-Proxy 支持 token 用量统计

@codecov
Copy link
Copy Markdown

codecov Bot commented Oct 13, 2025

Codecov Report

❌ Patch coverage is 36.91796% with 569 lines in your changes missing coverage. Please review.
✅ Project coverage is 14.24%. Comparing base (324eb01) to head (1e01cc5).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
...ernal/apps/ai-proxy/models/usage/token/dbclient.go 0.00% 132 Missing ⚠️
...common/usage/token_usage/estimators/impl/simple.go 63.15% 70 Missing and 7 partials ⚠️
...common/usage/token_usage/extractors/impl/openai.go 44.35% 64 Missing and 5 partials ⚠️
...ai-proxy/handlers/handler_token_usage/aggregate.go 57.76% 54 Missing and 14 partials ⚠️
...route/filters/request/force-stream-usage/filter.go 0.00% 52 Missing ⚠️
...s/ai-proxy/handlers/handler_token_usage/handler.go 0.00% 36 Missing ⚠️
...pps/ai-proxy/common/usage/token_usage/collector.go 31.91% 32 Missing ⚠️
internal/apps/ai-proxy/models/usage/token/table.go 0.00% 28 Missing ⚠️
...ps/ai-proxy/route/reverse_proxy/response_modify.go 26.31% 22 Missing and 6 partials ⚠️
...ernal/apps/ai-proxy/providers/ai-proxy/provider.go 0.00% 9 Missing ⚠️
... and 8 more
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #6609      +/-   ##
==========================================
+ Coverage   14.18%   14.24%   +0.06%     
==========================================
  Files        3849     3862      +13     
  Lines      385371   386298     +927     
==========================================
+ Hits        54658    55034     +376     
- Misses     325395   325911     +516     
- Partials     5318     5353      +35     
Flag Coverage Δ
by-github-actions 14.24% <36.91%> (+0.06%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
internal/apps/ai-proxy/common/auth/akutil/ak.go 26.66% <100.00%> (+26.66%) ⬆️
...roxy/common/usage/token_usage/proxy_types/types.go 100.00% <100.00%> (ø)
internal/apps/ai-proxy/handlers/errors.go 0.00% <ø> (ø)
internal/apps/ai-proxy/providers/dao/provider.go 0.00% <0.00%> (ø)
internal/pkg/gorilla/mux/provider.go 0.00% <0.00%> (ø)
...oxy/common/usage/token_usage/extractors/factory.go 0.00% <0.00%> (ø)
...ommon/usage/token_usage/extractors/impl/bedrock.go 0.00% <0.00%> (ø)
...oxy/common/usage/token_usage/estimators/factory.go 0.00% <0.00%> (ø)
...ommon/usage/token_usage/extractors/impl/bailian.go 0.00% <0.00%> (ø)
...ternal/apps/ai-proxy/handlers/permission/define.go 0.00% <0.00%> (ø)
... and 11 more

... and 8 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sfwn sfwn force-pushed the feat/ai-proxy-token-usage branch from 9208061 to cec3170 Compare October 14, 2025 06:42
@sfwn sfwn merged commit aae13df into erda-project:master Oct 14, 2025
29 checks passed
@sfwn sfwn deleted the feat/ai-proxy-token-usage branch October 14, 2025 07:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

2 participants