-
Notifications
You must be signed in to change notification settings - Fork 63
[DRAFT] feat: use RetryInfo metadata from retryable exceptions #1287
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: csm_2_instrumentation_advanced
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @daniel-sanche, 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 implements a proof-of-concept for a feature that enables the client to respect Highlights
Changelog
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 introduces a feature to respect RetryInfo metadata from retryable exceptions, allowing the backend to suggest retry backoff settings. However, a critical regression was introduced in google/cloud/bigtable/data/_metrics/tracked_retry.py where the signature of _track_retryable_error was changed without updating its call site in _track_terminal_error, leading to a TypeError when a timeout occurs. Additionally, I've provided suggestions to improve logging for debuggability and optimize a list comprehension for better performance and style.
|
|
||
| def _track_retryable_error( | ||
| operation: ActiveOperationMetric, | ||
| backoff_generator: TrackedBackoffGenerator, |
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.
The function _track_retryable_error has been updated to require a mandatory backoff_generator argument. However, the call site on line 118 (within _track_terminal_error) was not updated to provide this argument. This will lead to a TypeError and an application crash whenever a timeout occurs during an active retry attempt. Please ensure all call sites are updated to provide the required argument (e.g., _track_retryable_error(operation, operation.backoff_generator)(attempt_exc)).
| info_matches = [field for field in exc.details if isinstance(field, RetryInfo)] | ||
| if info_matches: | ||
| backoff_generator.set_from_exception_info(info_matches[0]) |
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.
The list comprehension [field for ...] builds a full list of all RetryInfo objects found in exc.details, even though only the first one is used. For efficiency, especially if exc.details could be large, it's better to use a generator expression with next() to find only the first match without iterating over the entire list unnecessarily.
| info_matches = [field for field in exc.details if isinstance(field, RetryInfo)] | |
| if info_matches: | |
| backoff_generator.set_from_exception_info(info_matches[0]) | |
| first_info = next((field for field in exc.details if isinstance(field, RetryInfo)), None) | |
| if first_info: | |
| backoff_generator.set_from_exception_info(first_info) |
Proof of concept of the RetryInfo feature. Allows the backend to set retry backoff settings
TODO: