GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(bigtable): add client side metric instrumentation to basic rpcs by daniel-sanche · Pull Request #16712 · googleapis/google-cloud-python

Conversation

@daniel-sanche

@daniel-sanche daniel-sanche commented Apr 17, 2026

Copy link
Copy Markdown
Contributor

Migration of googleapis/python-bigtable#1188 to the monorepo

This PR builds off of googleapis/python-bigtable#1187 to add instrumentation to basic data client rpcs (check_and_mutate, read_modify_write, sample_row_keys, mutate_row)

Metrics are not currently being exported anywhere, just collected and dropped. A future PR will add a GCP exporter to the system

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

gemini-code-assist[bot] reacted with eyes emoji
All reactions
  • 👀 1 reaction
daniel-sanche added 3 commits April 17, 2026 12:38
@daniel-sanche
moved over instrumentation code
8a3af45
@daniel-sanche
refactored system tests
cf58c57
@daniel-sanche
updated tests
00618f8
@daniel-sanche
daniel-sanche requested a review from a team as a code owner April 17, 2026 20:19
gemini-code-assist[bot]
gemini-code-assist Bot reviewed Apr 17, 2026
View reviewed changes

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

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 integrates client-side metrics tracking into the Bigtable data client for both asynchronous and synchronous implementations. It wraps key operations—including sample_row_keys, mutate_row, check_and_mutate_row, and read_modify_write_row—with metrics collection logic and introduces a tracked_retry wrapper to monitor retry attempts. Additionally, the PR refactors system tests by consolidating fixtures into a shared SystemTestRunner class and adds new system tests specifically for metrics. Feedback focuses on regressions in retry logic where critical arguments like sleep_generator and exception_factory were omitted in the transition to tracked_retry. There are also suggestions to improve resource cleanup in test fixtures and to relax restrictive timing assertions in tests to prevent flakiness.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread packages/google-cloud-bigtable/google/cloud/bigtable/data/_async/client.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread packages/google-cloud-bigtable/google/cloud/bigtable/data/_async/client.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread packages/google-cloud-bigtable/google/cloud/bigtable/data/_sync_autogen/client.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread packages/google-cloud-bigtable/google/cloud/bigtable/data/_sync_autogen/client.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread packages/google-cloud-bigtable/tests/system/data/__init__.py Outdated
),
clusters=cluster_config,
)
operation.result(timeout=240)

@gemini-code-assist gemini-code-assist Bot Apr 17, 2026

Copy link
Copy Markdown
Contributor

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.

medium

If operation.result(timeout=240) raises an exception (e.g., a TimeoutError), the fixture will stop execution and the delete_instance call in the teardown phase will never be reached. This can lead to leaked Bigtable instances in the test project. Consider wrapping the creation and yield in a try...finally block or ensuring cleanup happens even on creation failure.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread packages/google-cloud-bigtable/tests/system/data/test_metrics_async.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@daniel-sanche
fixed lint
ead3bf1
@daniel-sanche daniel-sanche added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Apr 21, 2026
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Apr 21, 2026
daniel-sanche and others added 4 commits April 21, 2026 12:39
@daniel-sanche
Merge branch 'main' into bigtable_csm_1_basic_instrumentation
af0beba
@daniel-sanche
regenerated files
d0c03d0
@daniel-sanche
fixed mtls tests
01f1739
@daniel-sanche
fixed format
d40fa0a
@daniel-sanche daniel-sanche mentioned this pull request Apr 21, 2026
feat: added client side metric instrumentation to read_rows and mutate_rows #16758
Merged
mutianf
mutianf reviewed Apr 23, 2026
View reviewed changes

@mutianf mutianf left a comment

Copy link
Copy Markdown
Contributor

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.

some final nit otherwise lgtm

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread packages/google-cloud-bigtable/google/cloud/bigtable/data/_helpers.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread packages/google-cloud-bigtable/tests/system/data/test_metrics_async.py
# validate operation
operation = handler.completed_operations[0]
assert isinstance(operation, CompletedOperationMetric)
assert operation.final_status.value[0] == 0

@mutianf mutianf Apr 23, 2026

Copy link
Copy Markdown
Contributor

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.

why is this final_status.value[0] and not just final_status.value? or final_status.name = 'OK'?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@daniel-sanche daniel-sanche May 2, 2026

Copy link
Copy Markdown
Contributor Author

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.

value is a tuple of (0, "ok"). We could just do final_status.name == 'OK' if you think that's clearer though

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@mutianf mutianf May 7, 2026

Copy link
Copy Markdown
Contributor

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 just noticed that some other tests are using final_status.name :)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread packages/google-cloud-bigtable/tests/system/data/test_metrics_async.py
for i in range(num_retryable):
attempt = handler.completed_attempts[i]
assert isinstance(attempt, CompletedAttemptMetric)
assert attempt.end_status.name == "ABORTED"

@mutianf mutianf Apr 23, 2026

Copy link
Copy Markdown
Contributor

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.

carry over my comment from before, I don't think we retry aborted error for mutate row by default, so maybe use unavailable instead? And also a little suprised that this test passes?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@daniel-sanche daniel-sanche May 2, 2026

Copy link
Copy Markdown
Contributor Author

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.

We allow the user to set custom retryable errors, which is what the test is doing here. So that's why it passes.

I can't remember for sure why I chose to use explicit retryable errors here instead of the default. Maybe just so the test makes sense even if you don't know the defaults. I could probably switch it to UNAVAILABLE though if you prefer

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

mutianf reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
mutianf
mutianf reviewed Apr 29, 2026
View reviewed changes
Comment thread packages/google-cloud-bigtable/google/cloud/bigtable/data/_async/client.py
)
return [(s.row_key, s.offset_bytes) async for s in results]

return await tracked_retry(

@mutianf mutianf Apr 29, 2026

Copy link
Copy Markdown
Contributor

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.

where did sleep_generator and exception_factory go?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@daniel-sanche daniel-sanche May 2, 2026

Copy link
Copy Markdown
Contributor Author

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.

tracked_retry contains them both. needed a custom versions of sleep_generator to report backoff, and exception_factory to report terminal errors metrics module. See go/bigtable-csm-python

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

mutianf reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread packages/google-cloud-bigtable/google/cloud/bigtable/data/_async/client.py
timeout=operation_timeout,
retry=None,
)
return result.predicate_matched

@mutianf mutianf Apr 29, 2026

Copy link
Copy Markdown
Contributor

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.

this is not wrapped in tracked_retry. Will the attempt level metrics (attempt latencies, server latencies and connectivity error count) still be recorded?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@daniel-sanche daniel-sanche May 2, 2026

Copy link
Copy Markdown
Contributor Author

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.

check_and_mutate shouldn't have retries, right?

But yes, a sngle attempt is will be recorded when this completes. The duration/gfe_latency data is captured, and will be exported as those metrics in the follow-up PR

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

mutianf reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread packages/google-cloud-bigtable/google/cloud/bigtable/data/_async/client.py
retry=None,
)
# construct Row from result
return Row._from_pb(result.row)

@mutianf mutianf Apr 29, 2026

Copy link
Copy Markdown
Contributor

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.

same question as check and mutate.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@daniel-sanche daniel-sanche May 2, 2026

Copy link
Copy Markdown
Contributor Author

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.

Yes, those are also captured here

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

mutianf reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@parthea parthea assigned daniel-sanche May 1, 2026
daniel-sanche and others added 2 commits May 4, 2026 16:00
@daniel-sanche @gemini-code-assist
Update packages/google-cloud-bigtable/tests/system/data/test_metrics_…
febdaac
…async.py

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@daniel-sanche
improve system test cleanup
c7b142d
mutianf
mutianf approved these changes May 7, 2026
View reviewed changes
@daniel-sanche
fix lint
e936535
@daniel-sanche
daniel-sanche enabled auto-merge (squash) May 8, 2026 22:57
@daniel-sanche
daniel-sanche merged commit 636af26 into main May 8, 2026
25 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@daniel-sanche
daniel-sanche deleted the bigtable_csm_1_basic_instrumentation branch May 8, 2026 23:07
daniel-sanche added a commit that referenced this pull request Jun 5, 2026
@daniel-sanche
feat: added client side metric instrumentation to read_rows and mutat…
4005e66
…e_rows (#16758)

Migration of googleapis/python-bigtable#1256 to
the monorepo

Builds off of
#16712 to add
instrumentation to read_rows and mutate_rows, along with the mutation
batcher
@release-please release-please Bot mentioned this pull request Jun 17, 2026
chore(main): release google-cloud-bigtable 2.39.0 #17497
Merged
parthea pushed a commit that referenced this pull request Jun 22, 2026
@release-please
chore(main): release google-cloud-bigtable 2.39.0 (#17497)
f6937b3
🤖 I have created a release *beep* *boop*
---


##
[2.39.0](google-cloud-bigtable-v2.38.0...google-cloud-bigtable-v2.39.0)
(2026-06-22)


### Features

* added client side metric instrumentation to read_rows and mutate_rows
([#16758](#16758))
([4005e66](4005e66))
* **bigtable:** add client side metric instrumentation to basic rpcs
([#16712](#16712))
([636af26](636af26))
* **bigtable:** add view_parameters support to execute_query
([#17382](#17382))
([2695aad](2695aad))
* support row_range in sample_row_keys method
([#17330](#17330))
([384724c](384724c)),
closes
[#17329](#17329)
* update API sources and regenerate
([#17431](#17431))
([2e75c78](2e75c78))
* update googleapis and regenerate
([33ba3af](33ba3af))


### Bug Fixes

* **bigtable:** ensure deadline is respected for read_rows_sharded
([#17352](#17352))
([6cc890b](6cc890b))
* require Python 3.10+
([#17245](#17245))
([200b0d3](200b0d3))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
chalmerlowe pushed a commit that referenced this pull request Jun 25, 2026
@release-please @chalmerlowe
chore(main): release google-cloud-bigtable 2.39.0 (#17497)
d39095b
🤖 I have created a release *beep* *boop*
---


##
[2.39.0](google-cloud-bigtable-v2.38.0...google-cloud-bigtable-v2.39.0)
(2026-06-22)


### Features

* added client side metric instrumentation to read_rows and mutate_rows
([#16758](#16758))
([4005e66](4005e66))
* **bigtable:** add client side metric instrumentation to basic rpcs
([#16712](#16712))
([636af26](636af26))
* **bigtable:** add view_parameters support to execute_query
([#17382](#17382))
([2695aad](2695aad))
* support row_range in sample_row_keys method
([#17330](#17330))
([384724c](384724c)),
closes
[#17329](#17329)
* update API sources and regenerate
([#17431](#17431))
([2e75c78](2e75c78))
* update googleapis and regenerate
([33ba3af](33ba3af))


### Bug Fixes

* **bigtable:** ensure deadline is respected for read_rows_sharded
([#17352](#17352))
([6cc890b](6cc890b))
* require Python 3.10+
([#17245](#17245))
([200b0d3](200b0d3))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
@release-please release-please Bot mentioned this pull request Jul 15, 2026
chore(main): release google-cloud-bigtable 0.1.0 #17719
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@mutianf mutianf mutianf approved these changes
+1 more reviewer
@gemini-code-assist gemini-code-assist[bot] gemini-code-assist[bot] left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@daniel-sanche daniel-sanche

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@daniel-sanche @mutianf @yoshi-kokoro
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.