-
Notifications
You must be signed in to change notification settings - Fork 985
refactor(agents-api): centralize usage tracking and remove deprecated metrics #1513
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: dev
Are you sure you want to change the base?
Conversation
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
|||||||||
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.
Caution
Changes requested ❌
Reviewed everything up to dd913f1 in 2 minutes and 4 seconds. Click for details.
- Reviewed
267lines of code in5files - Skipped
0files when reviewing. - Skipped posting
2draft comments. View those below. - Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. src/agents-api/agents_api/clients/litellm.py:121
- Draft comment:
Instead of using print for logging errors in the usage tracking try/except block, consider using a logging framework. - Reason this comment was not posted:
Comment was not on a location in the diff, so it can't be submitted as a review comment.
2. src/agents-api/agents_api/clients/litellm.py:15
- Draft comment:
There's an unexpected, stray closing parenthesis at the beginning of the file ()). This appears to be a typographical error and should be removed. - Reason this comment was not posted:
Comment was not on a location in the diff, so it can't be submitted as a review comment.
Workflow ID: wflow_q29I29lQyFgHjxEa
You can customize by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.
Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
…into usage-tracking
|
please review - @Ahmad-mtos |
User description
resolves: #1468
PR Type
Enhancement
Description
Centralize usage tracking logic into dedicated module
Remove deprecated metrics from individual router files
Consolidate Prometheus metrics and database tracking
Improve code organization and maintainability
Changes diagram
Changes walkthrough 📝
litellm.py
Update LiteLLM client to use centralized trackingsrc/agents-api/agents_api/clients/litellm.py
track_completion_usagetrack_usagecall with new functionusage_tracker.py
Add centralized usage tracking utilitiessrc/agents-api/agents_api/common/utils/usage_tracker.py
track_completion_usagefor non-streaming responsestrack_streaming_usagefor streaming responsescreate_response.py
Migrate response router to centralized trackingsrc/agents-api/agents_api/routers/responses/create_response.py
total_tokens_per_userimportchat.py
Migrate chat router to centralized trackingsrc/agents-api/agents_api/routers/sessions/chat.py
metrics.py
Remove deprecated metrics modulesrc/agents-api/agents_api/routers/sessions/metrics.py
total_tokens_per_userCounter definition