Skip to content

chore(gax): add AttemptInterceptor to ClientConfig#5966

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

chore(gax): add AttemptInterceptor to ClientConfig#5966
olavloite wants to merge 3 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
Comment thread src/gax/src/attempt_interceptor_internal.rs
Comment thread src/gax-internal/tests/grpc_simple_request.rs
@codecov

codecov Bot commented Jun 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.71%. Comparing base (187952a) to head (b65e56d).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff            @@
##             main    #5966    +/-   ##
========================================
  Coverage   97.71%   97.71%            
========================================
  Files         242      243     +1     
  Lines       60976    61078   +102     
========================================
+ Hits        59582    59683   +101     
- Misses       1394     1395     +1     

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

1 participant