Skip to content

Conversation

@daniel-sanche
Copy link
Contributor

Builds off of #1188 to add instrumentation to read_rows and mutate_rows, along with the mutation batcher

@product-auto-label product-auto-label bot added size: xl Pull request size is extra large. api: bigtable Issues related to the googleapis/python-bigtable API. labels Jan 15, 2026
@gemini-code-assist
Copy link

Summary of Changes

Hello @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 enhances the Bigtable client library by integrating robust client-side metric instrumentation. It provides granular insights into the performance and behavior of read_rows and mutate_rows operations, including those handled by the mutation batcher. This allows developers to better understand latency, retry patterns, and resource utilization at both the operation and individual attempt levels, facilitating performance optimization and debugging.

Highlights

  • Client-Side Metric Instrumentation: Introduced client-side metric instrumentation for read_rows and mutate_rows operations, including the mutation batcher, to capture detailed performance data.
  • Metric Tracking for Operations and Attempts: Operations now track overall duration, final status, streaming status, cluster/zone information, and flow throttling time. Individual attempts within an operation track duration, end status, backoff time, GFE latency, and application blocking time.
  • Integration with Retry Logic: The new tracked_retry mechanism wraps existing retry logic to seamlessly integrate metric collection for each attempt and the overall operation.
  • Comprehensive Test Coverage: Added extensive system and unit tests to validate metric collection for various scenarios, including successful operations, retries, timeouts, unauthorized access, and mid-stream failures for both synchronous and asynchronous clients.

🧠 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 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 by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

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 pull request 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

  1. 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.

Copy link

@gemini-code-assist gemini-code-assist bot left a 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 client-side metric instrumentation for read_rows and mutate_rows operations, which is a valuable addition for monitoring and performance analysis. The changes are well-structured, using a tracked_retry wrapper to cleanly inject metrics logic into existing retry mechanisms. The refactoring of read_row and row_exists methods in the client is a good improvement, enhancing code reuse and ensuring consistent metric coverage. The new system tests are comprehensive and cover a wide range of success and failure scenarios, which is excellent. I have a couple of minor suggestions to improve code clarity by removing a type: ignore directive. Overall, this is a solid contribution.

Comment on lines +323 to +326
if self._operation_metric.active_attempt is not None:
self._operation_metric.active_attempt.application_blocking_time_ns += ( # type: ignore
time.monotonic_ns() - block_time
)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To improve readability and avoid the type: ignore, you could introduce a local variable for self._operation_metric.active_attempt. This helps the type checker understand that the object is not None within the conditional block.

active_attempt = self._operation_metric.active_attempt
if active_attempt is not None:
    active_attempt.application_blocking_time_ns += (
        time.monotonic_ns() - block_time
    )

Comment on lines +269 to +272
if self._operation_metric.active_attempt is not None:
self._operation_metric.active_attempt.application_blocking_time_ns += (
time.monotonic_ns() - block_time
)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For consistency and improved readability, you could introduce a local variable for self._operation_metric.active_attempt here as well. This makes the logic clearer and aligns it with the suggested change in the async version of this file.

active_attempt = self._operation_metric.active_attempt
if active_attempt is not None:
    active_attempt.application_blocking_time_ns += (
        time.monotonic_ns() - block_time
    )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: bigtable Issues related to the googleapis/python-bigtable API. size: xl Pull request size is extra large.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant