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

Đang mở
#18,656 0 bình luận 0 reaction 1 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@olavloite đang làm issue này rồi.

Từ ngày 13/10/2026.

Đánh giá

Issue này chưa được đánh giá.

Mô tả

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.

Ngôn ngữ chính
Python
Star
5.4k
Fork
1.8k
Merge trung bình
2 ngày 7 giờ
Pull request đã merge (30 ngày)
173

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của googleapis/google-cloud-python

Tất cả issue của googleapis/google-cloud-python

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.