Skip to content

feat(storage): record gcp.storage.client.retries for mid-stream and HTTP retries - #15226

Open
nidhiii-27 wants to merge 7 commits into
feat/storage-retries-metric-corefrom
feat/storage-retries-metric-streams-http
Open

nidhiii-27 wants to merge 7 commits into
feat/storage-retries-metric-corefrom
feat/storage-retries-metric-streams-http

Conversation

@nidhiii-27

@nidhiii-27 nidhiii-27 commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Stacked on #15225.

Extends gcp.storage.client.retries coverage beyond Retrying.DefaultRetrier to mid-stream download retries and google-http-client internal retries.

Changes

  • GapicUnbufferedReadableByteChannel / ApiaryUnbufferedReadableByteChannel: record errors + retries for retried mid-stream ReadObject failures, and errors only for terminal (non-retryable) mid-stream failures.
  • StorageHttpMetricsInterceptor: store the status of a failed attempt that google-http-client will retry (>= 400, or 0 for an IOException, only when the handler returned true and retries remain) and record retries once the next attempt starts. A handled 3xx records nothing.
  • StorageMetricsContext.recordAttemptFailure(String errorType, long httpStatusCode): that internally retried failed attempt (e.g. 401 credential refresh, IOException) also records attempts/errors with the same attributes as Retrying, when a metrics context is active. Each failed attempt is counted exactly once; the final attempt is still recorded only by Retrying.
  • Unit tests in GapicUnbufferedReadableByteChannelTest, ApiaryUnbufferedReadableByteChannelTest, and StorageHttpMetricsInterceptorTest.

[Generated-by: AI]

@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 tracking and recording of mid-stream retries and error metrics in both Apiary and Gapic unbuffered readable byte channels, as well as HTTP interceptors. It exposes StorageMetricsContext from the Retrier interface and adds corresponding unit tests. One improvement was suggested in ApiaryUnbufferedReadableByteChannel to reuse the translated StorageException when recording mid-stream retries, ensuring more precise error/retry metrics are captured instead of passing the raw IOException.

@nidhiii-27
nidhiii-27 requested a review from cpriti-os November 25, 2026 10:24
@nidhiii-27
nidhiii-27 marked this pull request as ready for review November 25, 2026 10:25
@nidhiii-27
nidhiii-27 requested review from a team as code owners November 25, 2026 10:25

@cpriti-os cpriti-os 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.

Initial review

…unt terminal mid-stream errors

- StorageHttpMetricsInterceptor keeps the status of a failed attempt that
  google-http-client will retry (>= 400, or no response for an IOException) and
  records gcp.storage.client.retries once the next attempt starts. This drops the
  isRetry plumbing and no longer records a retry for a handled 3xx.
- The internally retried failed attempt also records gcp.storage.client.attempts
  and gcp.storage.client.errors via StorageMetricsContext.recordAttemptFailure,
  since Retrying only observes the final outcome of HttpRequest.execute().
- Apiary/Gapic unbuffered read channels record gcp.storage.client.errors for
  terminal (non-retryable) mid-stream failures.

[Generated-by: AI]
…est for Java 8 compatibility

Replace Mockito.mock(StreamController.class) with TestUtils.nullStreamController()
in stubMidStreamReadFailure to avoid ByteBuddy JDK 8 failures when copying JSpecify
@NullMarked annotations from StreamController.

[Generated-by: AI]
…ic-streams-http

# Conflicts:
#	java-storage/google-cloud-storage/src/main/java/com/google/cloud/storage/StorageHttpMetricsInterceptor.java
#	java-storage/google-cloud-storage/src/test/java/com/google/cloud/storage/StorageHttpMetricsInterceptorTest.java
Pull in cdca421 (from feat/storage-grpc-veneer-operation-metrics / #14729) to replace Mockito.mock(StreamController.class) with TestUtils.nullStreamController() in GrpcStorageImplTest for JDK 8 compatibility.

[Generated-by: AI]
nidhiii-27 added a commit that referenced this pull request Dec 4, 2026
…rage-request-active-metric

Pull in 37a28a2 (cdca421) from base PR #15226 to replace Mockito.mock(StreamController.class) with TestUtils.nullStreamController() in GrpcStorageImplTest for JDK 8 compatibility.

[Generated-by: AI]

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-generated Pull Request generated by AI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants