Record streaming attempt and front-end metrics when PartialResultSet.last=True is observed

未關閉
#18,656 0 則留言 0 個 reaction 已指派 1 人 在 GitHub 檢視

維護者通常 1 天內回覆

@olavloite 已經在處理了。

開始於 2026年10月13日。

評估

這個 Issue 還沒有評估資料。

描述

api: spanner
Description

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).

However, _StreamingResponseWrapper in metrics_interceptor.py currently defers recording attempt completion (attempt_latencies) and front-end timing metrics (gfe_latencies, afe_latencies) until StopIteration is raised:
https://github.com/googleapis/google-cloud-python/blob/main/packages/google-cloud-spanner/google/cloud/spanner_v1/metrics/metrics_interceptor.py

This causes two issues:

  1. 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.
  2. 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.

主要語言
Python
星號
5.4k
分支
1.8k
平均合併
2 天 7 小時
30 天內合併 PR
173

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

googleapis/google-cloud-python 的其他 Issue

查看 googleapis/google-cloud-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。