Repository navigation
feat(storage): record gcp.storage.client.retries for mid-stream and HTTP retries - #15226
Open
nidhiii-27 wants to merge 7 commits into
Open
nidhiii-27 wants to merge 7 commits into
nidhiii-27 wants to merge 7 commits into
Conversation
…TTP retries [Generated-by: AI]
Contributor
There was a problem hiding this comment.
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.
cpriti-os
requested changes
Nov 25, 2026
cpriti-os
reviewed
Nov 26, 2026
…ries-metric-streams-http [Generated-by: AI]
…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]
cpriti-os
approved these changes
Nov 26, 2026
…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
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Stacked on #15225.
Extends
gcp.storage.client.retriescoverage beyondRetrying.DefaultRetrierto mid-stream download retries and google-http-client internal retries.Changes
GapicUnbufferedReadableByteChannel/ApiaryUnbufferedReadableByteChannel: recorderrors+retriesfor retried mid-streamReadObjectfailures, anderrorsonly 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 anIOException, only when the handler returned true and retries remain) and recordretriesonce 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 recordsattempts/errorswith the same attributes asRetrying, when a metrics context is active. Each failed attempt is counted exactly once; the final attempt is still recorded only byRetrying.GapicUnbufferedReadableByteChannelTest,ApiaryUnbufferedReadableByteChannelTest, andStorageHttpMetricsInterceptorTest.[Generated-by: AI]