Skip to content

Conversation

@danieljbruce
Copy link
Contributor

@danieljbruce danieljbruce commented Jul 10, 2025

Description

Much like this change, this PR adds support for collecting client side metrics for mutateRows calls. This is a method that we want to collect client side metrics for.

Impact

This allows us to look at client side metrics for all mutateRows calls

Testing

All the tests that apply to readRows now also apply to mutateRows tests. This adds testing to ensure the metrics handlers get the right data, that the test doesn't time out and that the call to export the metrics succeeds.

Just a note that the readRows tests were copy pasted to a file that contains both the readrows tests and mutate rows tests because there have been small refactors and I didn't want to make a diff that was difficult to read. So we can delete the old file if necessary.

@product-auto-label product-auto-label bot added size: xl Pull request size is extra large. api: bigtable Issues related to the googleapis/nodejs-bigtable API. labels Jul 10, 2025
@danieljbruce danieljbruce marked this pull request as ready for review July 10, 2025 17:46
@danieljbruce danieljbruce requested review from a team as code owners July 10, 2025 17:46
@product-auto-label product-auto-label bot added size: l Pull request size is large. and removed size: xl Pull request size is extra large. labels Jul 10, 2025
setTimeout(makeNextBatchRequest, nextDelay);
return;
}
metricsCollector.onOperationComplete(err ? err.code : 0);

Choose a reason for hiding this comment

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

why is the operation complete here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because in this case the error is not retryable so we expect the operation to end. ie. the setTimeout call does the request again.


metricsCollector.onOperationStart();
const makeNextBatchRequest = () => {
metricsCollector.onAttemptStart();

Choose a reason for hiding this comment

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

these scattered onAttemptStart and onAttemptComplete lines make me a bit nervous. Especially since we have to repeat them across rpcs. Is there a way to encapsulate these better?

Maybe wrap the stream object itself? And wrap the callbacks?

Let me know if this makes sense to you. I can try to come up with some ideas if needed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Some ideas:

  1. We could make the first call to onAttemptStart automatically call onOperationStart right away.
  2. I like the idea of wrapping the callbacks so that it calls onOperationComplete just before we call the callback. I think that would clean things up.
  3. We could consider implicitly calling onAttemptComplete at the start of onAttemptStart to implicitly end the last attempt, but then I think the attempt latency would be off because it would include the retry delay so maybe this is not such a great option.
  4. All calls flow through the request method. We could consider allowing request to accept hooks that get called when an attempt starts or when an attempt ends, but I'm not sure I like this idea. It makes this method even more complex and this is a public facing method. Even though users shouldn't really be using this method directly, it would still change a public API surface. At most I would consider taking this as a backlog item and doing it later.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I only ended up adopting change #2. I think #1 has the downside that we lose flexibility and we only save 1 line of code.

Choose a reason for hiding this comment

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

Thanks, those changes look a lot better. I think there are still improvements to be had, but this is a great start

@product-auto-label product-auto-label bot added size: xl Pull request size is extra large. and removed size: l Pull request size is large. labels Jul 14, 2025
@danieljbruce danieljbruce added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jul 17, 2025
@danieljbruce danieljbruce added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jul 21, 2025
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jul 21, 2025
Copy link

@daniel-sanche daniel-sanche left a comment

Choose a reason for hiding this comment

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

My only remaining concern is this thread, where we need to confirm which error code to log for successful rpcs with failed mutations

@danieljbruce danieljbruce added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jul 25, 2025
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jul 25, 2025
@danieljbruce danieljbruce added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jul 28, 2025
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jul 28, 2025
Copy link

@daniel-sanche daniel-sanche left a comment

Choose a reason for hiding this comment

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

LGTM, after tests pass

@danieljbruce danieljbruce merged commit 7601e4d into main Jul 28, 2025
20 of 23 checks passed
@danieljbruce danieljbruce deleted the 359913994-mutate-rows branch July 28, 2025 18:34
gcf-merge-on-green bot pushed a commit that referenced this pull request Aug 11, 2025
🤖 I have created a release *beep* *boop*
---


## [6.3.0](https://github.com/googleapis/nodejs-bigtable/compare/v6.2.0...v6.3.0) (2025-08-11)


### Features

* Add client side metrics for checkAndMutateRow calls ([#1661](https://github.com/googleapis/nodejs-bigtable/issues/1661)) ([c258ea1](https://github.com/googleapis/nodejs-bigtable/commit/c258ea1b29203aad3eaaf9cfe64ddabb8c1018bf))
* Add client side metrics for readModifyWriteRow calls ([#1656](https://github.com/googleapis/nodejs-bigtable/issues/1656)) ([2129312](https://github.com/googleapis/nodejs-bigtable/commit/2129312401bf9f5b8e51b13ac576cb765de401df))
* Client side metrics support for mutateRows ([#1638](https://github.com/googleapis/nodejs-bigtable/issues/1638)) ([7601e4d](https://github.com/googleapis/nodejs-bigtable/commit/7601e4da115ff6a5da411cc857917b579c70ced7))
* Collect client side metrics for sampleRowKeys calls ([#1660](https://github.com/googleapis/nodejs-bigtable/issues/1660)) ([6ed98fa](https://github.com/googleapis/nodejs-bigtable/commit/6ed98faefe446e67f83fd5394aae30374fd3ec3a))
* For client side metrics, record metrics as MUTATE_ROW for single row mutates ([#1650](https://github.com/googleapis/nodejs-bigtable/issues/1650)) ([f190a8c](https://github.com/googleapis/nodejs-bigtable/commit/f190a8c322498ddfbe73406759a43a268c16bdc4))
* Record ReadRows application latencies for client side metrics ([#1647](https://github.com/googleapis/nodejs-bigtable/issues/1647)) ([8af801b](https://github.com/googleapis/nodejs-bigtable/commit/8af801b3ecd7ff5e30e6c8cc67bd4123bdf34ee9))


### Bug Fixes

* FirstResponseLatencies should only be collected for readRows calls ([#1658](https://github.com/googleapis/nodejs-bigtable/issues/1658)) ([99cf5a6](https://github.com/googleapis/nodejs-bigtable/commit/99cf5a6010249ed0eedd88f23b2d32cacb106c07))

---
This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
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/nodejs-bigtable API. size: xl Pull request size is extra large.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants