Skip to content

feat(storage): record gcp.storage.client.network.io debug metric on gRPC - #15230

Open
nidhiii-27 wants to merge 6 commits into
feat/storage-server-unreached-metricfrom
feat/storage-network-io-metric
Open

nidhiii-27 wants to merge 6 commits into
feat/storage-server-unreached-metricfrom
feat/storage-network-io-metric

Conversation

@nidhiii-27

Copy link
Copy Markdown
Contributor

Summary

Stacked on #15229.

Adds Debug-tier gcp.storage.client.network.io (LongCounter, unit By) on gRPC calls to track socket-layer wire bytes transmitted and received.

Changes

  • StorageClientMetrics: add recordNetworkIo(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.direction with values transmit and receive).
  • StorageGrpcMetricsInterceptor: attach a ClientStreamTracer.Factory via callOptions.withStreamTracerFactory(...) when network.io is enabled, accumulating outbound/inbound wire bytes across the stream and flushing totals on onClose.
  • Unit tests in StorageClientMetricsTest and StorageGrpcMetricsInterceptorTest covering symmetric/asymmetric byte counts, disabled debug metrics, and exact attribute sets.

[Generated-by: AI]

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]

@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 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

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]
@nidhiii-27
nidhiii-27 marked this pull request as ready for review November 26, 2026 06:05
@nidhiii-27
nidhiii-27 requested review from a team as code owners November 26, 2026 06:05
@nidhiii-27
nidhiii-27 requested review from Dhriti07 and cpriti-os and removed request for a team November 26, 2026 06:05

@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

metrics.recordServerUnreached(
otelContext, operationName, networkPath, errorType);
}
if (networkIoTracerFactory != null) {

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.

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) {

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.

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);

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.

Nit: Can we also call inboundWireSize(0L) and inboundWireSize(-10L) here to cover its non-positive guard alongside outboundWireSize?

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