You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Record streaming attempt and front-end metrics when PartialResultSet.last=True is observed #18656
In google-cloud-spanner, streaming queries that receive PartialResultSet.last = True hand off the underlying response iterator to _GLOBAL_STREAM_DRAINER to drain trailing metadata to EOF asynchronously on a background worker thread (in snapshot.py).
Metric Timing Inaccuracy: Attempt latency should measure when the operation actually completes from an outside observer's perspective (i.e. when PartialResultSet.last = True is received by the caller), rather than including time spent waiting in the background drainer queue or consuming trailing stream metadata.
Race Condition with Metrics Readers: Callers that complete a query and immediately collect or inspect metrics observe missing attempt_latencies, gfe_latencies, and afe_latencies because the background drainer thread has not yet reached EOF.
Proposed Solution
The client should measure attempt completion and record front-end metrics as soon as PartialResultSet.last == True is observed on the stream, rather than waiting for StopIteration during background stream draining.
Activity