Skip to content

chore(spanner): add LatencyTracker interface and default implementation#12729

Open
olavloite wants to merge 1 commit intomainfrom
spanner-latency-tracker
Open

chore(spanner): add LatencyTracker interface and default implementation#12729
olavloite wants to merge 1 commit intomainfrom
spanner-latency-tracker

Conversation

@olavloite
Copy link
Copy Markdown
Contributor

Adds an internal LatencyTracker interface and a default implementation that allows the client to track the latency of requests. This can be used for automatic replica selection and load balancing.

@olavloite olavloite requested review from a team as code owners April 9, 2026 13:46
Copy link
Copy Markdown
Contributor

@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 a new latency tracking mechanism using Exponentially Weighted Moving Average (EWMA), including a LatencyTracker interface, its EwmaLatencyTracker implementation, and comprehensive unit tests. The primary feedback concerns the initial state of the EwmaLatencyTracker, specifically that an uninitialized tracker currently returns a score of 0.0. This is problematic as it implies a perfect score, potentially leading to incorrect load balancing decisions. It is suggested that an uninitialized tracker should instead return Double.POSITIVE_INFINITY to accurately reflect its unmeasured state, and a new test case should be added to verify this behavior.

@olavloite olavloite force-pushed the spanner-latency-tracker branch from bc8842b to 274308d Compare April 9, 2026 14:33
Adds an internal LatencyTracker interface and a default implementation that allows the
client to track the latency of requests. This can be used for automatic replica
selection and load balancing.
@olavloite olavloite force-pushed the spanner-latency-tracker branch from 274308d to c50bb2e Compare April 9, 2026 14:36
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