Repository navigation
feat(storage): record gRPC stall.duration and Watchdog TIMEOUT classification - #15231
nidhiii-27 wants to merge 6 commits into
Conversation
…fication Add Debug-tier gcp.storage.client.stall.duration (unit "s", exact 8-key attributes) and a zero-race Watchdog timeout callback scope between StorageGrpcMetricsInterceptor and GapicUnbufferedReadableByteChannel so GAX Watchdog aborts synchronously tag rpc.client.call.duration with error.type=TIMEOUT, record stall duration since the last received message, and avoid false server.unreached counts. [Generated-by: AI]
There was a problem hiding this comment.
Code Review
This pull request introduces watchdog timeout tracking and stall duration metrics for Google Cloud Storage. It updates the gRPC metrics interceptor to track the last activity time and record stall duration metrics when a watchdog timeout occurs, supported by new thread-local scope management in StorageMetricsContext. The review feedback highlights two concurrency-related improvements in StorageGrpcMetricsInterceptor.java: declaring lastActivityNanos as volatile to ensure proper memory visibility across threads, and replacing a raw boolean[] array with AtomicBoolean to guarantee thread-safe execution of the onClose metrics recording.
…stall-duration-metric [Generated-by: AI]
…stall-duration-metric Keep the shared releaseActive() exactly-once request.active decrement in the restructured recordOnCloseMetrics finally block. [Generated-by: AI]
interceptCall_watchdogTimeout_recordsStallDurationAndTimeoutErrorType already asserts the exact attribute set, unit, and debug-tier gating end to end. [Generated-by: AI]
…stall-duration-metric [Generated-by: AI]
…stall-duration-metric [Generated-by: AI]
| @Override | ||
| public void onMessage(@Nullable RespT message) { | ||
| long now = clock.nanoTime(); | ||
| lastActivityNanos = now; |
There was a problem hiding this comment.
Should we update lastActivityNanos after super.onMessage(message) returns so time spent blocked in ReadObjectObserver's queue isn't counted as server stall duration?
| } | ||
|
|
||
| @Test | ||
| public void interceptCall_watchdogTimeout_recordsStallDurationAndTimeoutErrorType() |
There was a problem hiding this comment.
Nit: Can we split these scenarios into separate @Test methods (so they don't share metric state) and add a debug-enabled case where Watchdog fires before the first onMessage?
| } | ||
|
|
||
| @Test | ||
| public void read_watchdogTimeout_notifiesWatchdogScopeSynchronously() throws IOException { |
There was a problem hiding this comment.
Nit: Could we also test a non-watchdog CancellationException inside enterWatchdogScope to verify the callback isn't triggered for normal cancellations?
Summary
Stacked on #15230.
Adds Debug-tier
gcp.storage.client.stall.duration(DoubleHistogram, units) on gRPC streaming reads and introduces a zero-race GAXWatchdogtimeout feedback hook betweenStorageGrpcMetricsInterceptorandGapicUnbufferedReadableByteChannel, resolving #14743#discussion_r4596591825.Changes
StorageClientMetrics: addrecordStallDuration(Context, double durationSeconds, String operationName, String rpcMethod, String networkPath)emitting exact 8-key attributes (gcp.client.service,gcp.client.version,gcp.client.artifact,rpc.system.name,server.address,gcp.storage.operation,rpc.method,network.path).StorageMetricsContext: addenterWatchdogScope(Runnable)andnotifyWatchdogTimeout()thread-local callback scope soWatchdogTimeoutExceptionsignals synchronously before the reader thread unblocks.GapicUnbufferedReadableByteChannel.ReadObjectObserver.onErrorImpl: invokeStorageMetricsContext.notifyWatchdogTimeout()synchronously whent instanceof WatchdogTimeoutExceptionbefore completingopenor enqueueingt.StorageGrpcMetricsInterceptor: tracklastActivityNanoson the listener and, whenonClosereceivesStatus.Code.CANCELLED, wrapsuper.onCloseinStorageMetricsContext.enterWatchdogScope(...)so real GAX Watchdog aborts synchronously tagrpc.client.call.durationwitherror.type = "TIMEOUT", recordstall.durationsince the last received message, and prevent falseserver.unreachedincrements (non-cancelled closes continue recording beforesuper.onClose).StorageClientMetricsTest,StorageMetricsContextTest,GapicUnbufferedReadableByteChannelTest, andStorageGrpcMetricsInterceptorTest(including real GAXWatchdog.createDuration(...)tests).[Generated-by: AI]