-
-
Notifications
You must be signed in to change notification settings - Fork 941
feat(usage): persist usage statistics #878
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
feat(usage): persist usage statistics #878
Conversation
Summary of ChangesHello @piexian, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a crucial feature for the service: the ability to persist usage statistics. By implementing functions to save and load these statistics to a JSON file, the service can now retain valuable usage data across restarts, providing a more complete and continuous record of activity. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
This pull request adds persistence for usage statistics, which is a great enhancement for retaining data across service restarts. The implementation correctly integrates with the service lifecycle. My review includes two main suggestions for the internal/usage/logger_plugin.go file to improve the robustness and maintainability of the new persistence logic. First, I recommend making the file save operation atomic to prevent data corruption in case of an unexpected shutdown. Second, I suggest replacing a magic string for the filename with a constant to improve code clarity.
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.
Pull request overview
This pull request adds persistent storage for usage statistics to ensure data is retained across service restarts. The implementation saves statistics to a JSON file in the same directory as the config file.
- Added persistence functions (
SetPersistPath,LoadStatistics,SaveStatistics) to save and load usage statistics - Integrated persistence into the service lifecycle by loading statistics on startup and saving on shutdown
- Changed the internal/usage package import from blank to named to enable calling the new persistence functions
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 9 comments.
| File | Description |
|---|---|
| sdk/cliproxy/service.go | Changed internal/usage import to named import and added calls to initialize persist path, load statistics on startup, and save statistics during shutdown |
| internal/usage/logger_plugin.go | Added persistence-related imports (encoding/json, os, path/filepath, logrus) and implemented three new functions for managing statistics persistence to/from a JSON file |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <[email protected]>
…statistics persistence
…auto-update, request timeout, multi-candidate, auth persistence Applied features from upstream PRs: - PR router-for-me#878: Usage statistics persistence (SetPersistPath, LoadStatistics, SaveStatistics) - PR router-for-me#877: Codex plan type credential filename handling - PR router-for-me#868: Claude request cloaking utilities (obfuscation, fake user IDs) - PR router-for-me#715: Auto-update command for self-updating binary - PR router-for-me#860: Configurable request timeout with RequestTimeout config - PR router-for-me#879: Gemini multi-candidate support (n param -> candidateCount) - PR router-for-me#869: Auth token persistence for non-Google OAuth providers Fixed build issues: - Added applyPayloadConfig wrapper function - Added originalTranslated computation in claude/antigravity/codex executors - Fixed model registry hook methods - Removed duplicate SanitizeFunctionName - Fixed gemini_schema placeholder logic for nested object properties Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
|
Sorry, we did not accept any pr about persist usage statistics |
This pull request introduces persistent storage for usage statistics in the service. It adds logic to save and load usage data to a file, ensuring statistics are retained across restarts. The changes include new functions for persistence, integration of these functions into the service lifecycle, and necessary dependency updates.
Usage statistics persistence:
SetPersistPath,LoadStatistics, andSaveStatisticsfunctions to handle saving and loading usage statistics to a JSON file (usage_stats.json). These functions use the configured path and provide error handling and logging. (internal/usage/logger_plugin.go)sdk/cliproxy/service.goto set the persistence path and load statistics on service start, and to save statistics on shutdown. (sdk/cliproxy/service.go) [1] [2] [3]encoding/json,os,path/filepath, andlogrusfor file operations and logging. (internal/usage/logger_plugin.go)