Repository navigation
feat(storage): record gcp.storage.client.network.io debug metric on gRPC - #15230
nidhiii-27 wants to merge 6 commits into
Conversation
Record Debug-tier gcp.storage.client.network.io (unit "By", exact 7-key attributes) on gRPC calls by attaching a ClientStreamTracer.Factory when debug metrics are enabled, accumulating transmit/receive wire bytes across streams and flushing on call close. [Generated-by: AI]
There was a problem hiding this comment.
Code Review
This pull request introduces network I/O tracking to the gRPC metrics interceptor by adding a recordNetworkIo method to StorageClientMetrics and implementing a NetworkIoTracerFactory in StorageGrpcMetricsInterceptor to trace inbound and outbound wire sizes. It also includes comprehensive unit tests to verify the recording of these metrics under various configurations. I have no feedback to provide.
…-network-io-metric [Generated-by: AI]
…-network-io-metric Resolve the StorageClientMetricsTest conflict: drop the duplicated record*_recordsExact* tests and narrow the network.io unit test to the skip-non-positive/disabled behavior (exact attributes, unit and directions stay covered by the interceptor test). [Generated-by: AI]
…-network-io-metric [Generated-by: AI]
…nit test [Generated-by: AI]
[Generated-by: AI]
| metrics.recordServerUnreached( | ||
| otelContext, operationName, networkPath, errorType); | ||
| } | ||
| if (networkIoTracerFactory != null) { |
There was a problem hiding this comment.
Should we track bytes and network.path per ClientStreamTracer in streamCreated and streamClosed instead of aggregating across streams and flushing in onClose, so retried or hedged streams on different paths aren't misattributed and late callbacks aren't missed?
| ClientStreamTracer.StreamInfo info, Metadata headers) { | ||
| return new ClientStreamTracer() { | ||
| @Override | ||
| public void outboundWireSize(long bytes) { |
There was a problem hiding this comment.
ClientStreamTracer only counts framed and deframed message payloads (missing unconsumed HTTP/2 receive-window bytes on cancelled reads and TLS overhead); can we hook into the Netty socket layer for actual TCP bytes or clarify the metric description if this approximation is intentional?
| stream1.outboundWireSize(128L); | ||
| stream1.outboundWireSize(0L); | ||
| stream1.outboundWireSize(-10L); | ||
| stream1.inboundWireSize(512L); |
There was a problem hiding this comment.
Nit: Can we also call inboundWireSize(0L) and inboundWireSize(-10L) here to cover its non-positive guard alongside outboundWireSize?
Summary
Stacked on #15229.
Adds Debug-tier
gcp.storage.client.network.io(LongCounter, unitBy) on gRPC calls to track socket-layer wire bytes transmitted and received.Changes
StorageClientMetrics: addrecordNetworkIo(Context, String networkPath, long transmitBytes, long receiveBytes)emitting exact 7-key attributes (gcp.client.service,gcp.client.version,gcp.client.artifact,rpc.system.name,server.address,network.path,network.io.directionwith valuestransmitandreceive).StorageGrpcMetricsInterceptor: attach aClientStreamTracer.FactoryviacallOptions.withStreamTracerFactory(...)whennetwork.iois enabled, accumulating outbound/inbound wire bytes across the stream and flushing totals ononClose.StorageClientMetricsTestandStorageGrpcMetricsInterceptorTestcovering symmetric/asymmetric byte counts, disabled debug metrics, and exact attribute sets.[Generated-by: AI]