Skip to content

feat: populate client_stats in AppendRowsRequest - #14614

Open
agrawal-siddharth wants to merge 1 commit into
googleapis:mainfrom
agrawal-siddharth:clientstats
Open

agrawal-siddharth wants to merge 1 commit into
googleapis:mainfrom
agrawal-siddharth:clientstats

Conversation

@agrawal-siddharth

Copy link
Copy Markdown
Contributor

No description provided.

@agrawal-siddharth
agrawal-siddharth requested review from a team as code owners October 9, 2026 03:16

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

Copy link
Copy Markdown
Contributor

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 adds the population of ClientStats with the request send timestamp (sendTimeMillis) on append requests in ConnectionWorker, along with a corresponding unit test to verify this behavior. The review feedback suggests avoiding unconditionally setting ClientStats on the request builder when it is empty (i.e., when the timestamp is null), as setting an empty Protobuf message causes hasClientStats() to return true, leading to unnecessary serialization overhead. It is recommended to check if the returned ClientStats is equal to the default instance before setting it.

}
firstRequestForTableOrSchemaSwitch = false;

originalRequestBuilder.setClientStats(createClientStats(wrapper));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

If createClientStats returns an empty ClientStats (when requestSendTimeStamp is null), calling setClientStats unconditionally will still set an empty ClientStats message on the builder. In Protobuf, setting an empty message field causes hasClientStats() to return true, which adds unnecessary serialization overhead and can mislead the backend. Since we prefer returning empty objects instead of null to minimize null pointer risks, we should check if the returned ClientStats is empty (i.e., equals ClientStats.getDefaultInstance()) before setting it on the builder.

Suggested change
originalRequestBuilder.setClientStats(createClientStats(wrapper));
ClientStats clientStats = createClientStats(wrapper);
if (!clientStats.equals(ClientStats.getDefaultInstance())) {
originalRequestBuilder.setClientStats(clientStats);
}
References
  1. Prefer returning empty objects (such as an empty ErrorDetails or empty collections) instead of null to minimize null pointer risks, and document this behavior in Javadocs (e.g., how to pair it with state checks like isDone()).

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant