chore(gax-internal): add attempt start and complete lifecycle hooks to AttemptInterceptor - #6315
Conversation
…o AttemptInterceptor Extend the internal AttemptInterceptor trait with on_attempt_start and on_attempt_complete callbacks to allow tracking per-attempt latency, metadata, and response headers across unary gRPC attempts. Bump google-cloud-gax-internal version to 0.7.17.
There was a problem hiding this comment.
Code Review
This pull request bumps the version of google-cloud-gax-internal to 0.7.17 and introduces new lifecycle hooks, on_attempt_start and on_attempt_complete, to the AttemptInterceptor trait. These hooks enable tracking of unary RPC attempt durations, response headers, and outcomes. The gRPC Client has been updated to invoke these hooks, and comprehensive unit and integration tests have been added to verify the new behavior. Additionally, several .unwrap() calls in tests were replaced with .expect() to align with the style guide. I have no feedback to provide.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6315 +/- ##
==========================================
+ Coverage 96.27% 96.28% +0.01%
==========================================
Files 283 283
Lines 73110 73313 +203
==========================================
+ Hits 70384 70587 +203
Misses 2726 2726 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
coryan
left a comment
There was a problem hiding this comment.
to allow tracking per-attempt latency,
We already have a way to do that.... Look at the implementation of transport-level metrics. This may be a good place to start:
Can you examine the other approach (maybe you already did) and let us know why it does not work in your case?
Yeah, looked into that possibility (sorry, I should have added that directly to the PR description). The short answer is 'While not utterly impossible, it would require major changes to
Or to quote a verbose friend of mine: 1. Why
|
| Requirement | WithTransportMetric / RequestRecorder |
AttemptInterceptor Lifecycle Hooks |
|---|---|---|
Response Headers (server-timing) |
❌ Not captured in TransportSnapshot |
✅ Directly passed as Option<&HeaderMap> |
| Spanner Metric Suite (8 instruments) | ❌ Hardcoded to gcp.client.attempt.duration |
✅ Delegated directly to Spanner's Observability |
Custom Monitored Resource (spanner_instance_client) |
❌ Hardcoded to generic OTel resource conventions | ✅ Managed by Spanner's SdkMeterProvider |
| Intermediate Attempt Notification | ❌ Encapsulated inside GAX retry loop | ✅ Direct callback per attempt |
Extend the internal AttemptInterceptor trait with on_attempt_start and on_attempt_complete callbacks to allow tracking per-attempt latency, metadata, and response headers across unary gRPC attempts.
Bump google-cloud-gax-internal version to 0.7.17.
Needed for #6311