-
Notifications
You must be signed in to change notification settings - Fork 2.4k
chore: Change live connection log level from info to debug #2600
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
Conversation
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.
Summary of Changes
Hello @ammmr, 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 aims to reduce excessive logging verbosity in production environments by adjusting the log level for live connection requests. Previously, detailed llm_request objects were logged at the info level, leading to unnecessary noise. The change reclassifies this specific log entry to the debug level, ensuring that detailed connection information is still available for debugging purposes without cluttering standard operational logs. This improves log readability and maintainability without impacting functionality.
Highlights
- Log Level Adjustment: Changed the logging level for
llm_requestobjects during live API connections frominfotodebug. - Production Log Reduction: This change significantly reduces log noise in production environments by moving detailed, debug-specific information out of standard info-level logs.
- Debugging Information Retention: The detailed
llm_requestinformation remains accessible for troubleshooting when debug-level logging is enabled.
Using Gemini Code Assist
The 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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.
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
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
|
Response from ADK Triaging Agent Hello @ammmr, thank you for creating this PR! Could you please add a Thanks! |
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 correctly addresses the issue of excessive log verbosity by changing the log level for live connection requests from info to debug. My review focuses on improving the consistency and safety of this logging. I've suggested using an existing helper function to format the debug log message, which prevents logging large data blobs and aligns with practices elsewhere in the file. I also recommended adding a concise info-level log to maintain essential observability for this operation.
| ) | ||
| llm_request.live_connect_config.tools = llm_request.config.tools | ||
| logger.info('Connecting to live with llm_request:%s', llm_request) | ||
| logger.debug('Connecting to live with llm_request:%s', llm_request) |
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.
While changing the log level to debug is a good step to reduce verbosity, the current implementation directly logs the llm_request object. This can still lead to very large log entries, especially if the request contains inline data (e.g., images), and is inconsistent with how requests are logged elsewhere in this file.
For consistency and to avoid logging potentially large data blobs, I suggest using the existing _build_request_log helper function, which is designed to create a safe and readable representation of the request. This function excludes raw byte data from logs.
Additionally, for better observability, you might consider adding a concise info-level log message that summarizes the connection attempt, similar to what's done in generate_content_async (lines 112-114). This would provide essential information in production logs without the excessive detail.
Here's a suggested implementation:
logger.info('Connecting to live for model: %s', llm_request.model)
logger.debug('Live connection request details: %s', _build_request_log(llm_request))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.
I don't understand the background of why this log was added, but I assume it's intended to output connection information and similar details.
_build_request_log appears to be a function designed to output contents and instruction, so I don't think it aligns with the intended purpose.
|
@ammmr thanks. the change make sense. But i think we can add another a short log at logger.log level. |
|
Thank you for the review! I appreciate your feedback. Just to clarify your suggestion - do you mean adding a brief info-level log message (e.g., just showing the model name or connection status) while keeping the detailed For example, something like: This way we could maintain visibility of connection events in production logs without the verbosity issue. Is this what you had in mind? |
Merge #2600 **Reason for this change:** Currently, the detailed llm_request object is logged at the info level when connecting to the live API. This causes two main issues: 1. Excessive log output with large instructions: When instructions are large, the unstructured log output becomes problematic. Since the logs are not structured, any newline characters in the instruction content cause each line to be output as a separate log entry, resulting in massive log output that floods the logging system. 2. Unnecessary verbosity in production: The detailed request information is primarily useful for debugging purposes and should not appear in standard info-level logs, especially when connections are established frequently. **Changes made:** - Changed logger.info to logger.debug in src/google/adk/models/google_llm.py at line 294 for the live connection logging statement. **Impact:** This change will: - Reduce log noise in production environments where info-level logging is enabled - Keep the detailed connection information available when debug-level logging is needed for troubleshooting - Improve log readability by showing only essential information at the info level **Before:** logger.info('Connecting to live with llm_request:%s', llm_request) **After:** logger.debug('Connecting to live with llm_request:%s', llm_request) This is a non-breaking change that only affects logging verbosity. Co-authored-by: Hangfei Lin <hangfei@google.com> COPYBARA_INTEGRATE_REVIEW=#2600 from ammmr:ammmr-info-to-debug-connect-log 36eab15 PiperOrigin-RevId: 829596092
Reason for this change:
Currently, the detailed llm_request object is logged at the info level when connecting to the live API. This causes two main issues:
newline characters in the instruction content cause each line to be output as a separate log entry, resulting in massive log output that floods the logging system.
especially when connections are established frequently.
Changes made:
Impact:
This change will:
Before:
logger.info('Connecting to live with llm_request:%s', llm_request)
After:
logger.debug('Connecting to live with llm_request:%s', llm_request)
This is a non-breaking change that only affects logging verbosity.