Skip to content

chore(gax-internal): add AttemptInterceptor#5966

Open
olavloite wants to merge 7 commits into
googleapis:mainfrom
olavloite:gax-attempt-interceptor
Open

chore(gax-internal): add AttemptInterceptor#5966
olavloite wants to merge 7 commits into
googleapis:mainfrom
olavloite:gax-attempt-interceptor

Conversation

@olavloite

Copy link
Copy Markdown
Contributor

Introduces an internal AttemptInterceptor trait in google-cloud-gax that allows modifying outgoing RPC headers (http::HeaderMap) on every attempt.

This is integrated into the gax-internal gRPC client and invoked on each unary and streaming attempt, passing the 1-based attempt number.

This hook is required by the Cloud Spanner client to inject the x-goog-spanner-request-id header with incrementing attempt numbers on retries and stream resumes.

The module is named attempt_interceptor_internal and hidden from the public documentation using the _internal-semver feature flag.

Introduces an internal `AttemptInterceptor` trait in `google-cloud-gax`
that allows modifying outgoing RPC headers (`http::HeaderMap`) on every
attempt.

This is integrated into the `gax-internal` gRPC client and invoked on
each unary and streaming attempt, passing the 1-based attempt number.

This hook is required by the Cloud Spanner client to inject the
`x-goog-spanner-request-id` header with incrementing attempt numbers
on retries and stream resumes.

The module is named `attempt_interceptor_internal` and hidden from the
public documentation using the `_internal-semver` feature flag.
@olavloite olavloite requested a review from a team as a code owner June 30, 2026 11:35

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

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 the AttemptInterceptor trait and integrates it into the gRPC client, allowing users to intercept and modify headers on each RPC attempt. It also adds corresponding unit and integration tests. The review feedback highlights a critical compilation issue where AttemptInterceptor must be explicitly implemented for Arc<dyn AttemptInterceptor> to allow proper resolution of Option<T>. Additionally, there are minor style guide violations in the test files where .unwrap() is used instead of .expect().

Comment thread src/gax/src/attempt_interceptor_internal.rs Outdated
Comment thread src/gax/src/attempt_interceptor_internal.rs Outdated
Comment thread src/gax-internal/tests/grpc_simple_request.rs
@codecov

codecov Bot commented Jun 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 82.75862% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.72%. Comparing base (ac6f825) to head (f5446cd).

Files with missing lines Patch % Lines
src/gax-internal/src/attempt_interceptor.rs 61.53% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5966      +/-   ##
==========================================
- Coverage   97.73%   97.72%   -0.01%     
==========================================
  Files         244      245       +1     
  Lines       61161    61182      +21     
==========================================
+ Hits        59776    59792      +16     
- Misses       1385     1390       +5     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@olavloite olavloite force-pushed the gax-attempt-interceptor branch from 70de7cd to b65e56d Compare June 30, 2026 12:25
@olavloite olavloite requested a review from a team as a code owner June 30, 2026 12:25
dbolduc added a commit that referenced this pull request Jun 30, 2026
olavloite added 3 commits July 8, 2026 14:54
Moves AttemptInterceptor to gax-internal and remove the configuration option
from ClientConfig in favor of a mutator on the internal gRPC client.
@olavloite

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

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 the AttemptInterceptor trait and integrates it into the gRPC client to allow intercepting and modifying outgoing RPC attempt headers, along with adding comprehensive integration tests. The review feedback suggests minor improvements: using the imported Arc type directly instead of its fully qualified path, dereferencing Arc with **self to avoid method resolution ambiguity, and replacing .unwrap() with .expect() in tests to align with the repository's style guide.

Comment thread src/gax-internal/src/grpc.rs Outdated
Comment thread src/gax-internal/src/attempt_interceptor.rs
Comment thread src/gax-internal/tests/grpc_retry_loop.rs
Comment thread src/gax-internal/tests/grpc_retry_loop.rs
Comment thread src/gax-internal/tests/grpc_streaming_request.rs Outdated
@olavloite olavloite force-pushed the gax-attempt-interceptor branch from 70375f2 to f5446cd Compare July 9, 2026 08:50
@olavloite

Copy link
Copy Markdown
Contributor Author

/gemini-review

@coryan coryan changed the title chore(gax): add AttemptInterceptor to ClientConfig chore(gax-internal): add AttemptInterceptor Jul 9, 2026
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.

2 participants