Skip to content

feat(storage): record gcp.storage.client.server.duration metric on gRPC - #15228

Open
nidhiii-27 wants to merge 5 commits into
feat/storage-request-active-metricfrom
feat/storage-server-duration-metric
Open

nidhiii-27 wants to merge 5 commits into
feat/storage-request-active-metricfrom
feat/storage-server-duration-metric

Conversation

@nidhiii-27

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

Copy link
Copy Markdown
Contributor

Summary

Stacked on #15227.

Adds Debug-tier gcp.storage.client.server.duration (DoubleHistogram, unit s) on gRPC calls by decoding the grpc-server-stats-bin response trailer.

Changes

  • StorageClientMetrics: add recordServerDuration(Context, double durationSeconds, String operationName, String networkPath) emitting exact 7-key attributes (gcp.client.service, gcp.client.version, gcp.client.artifact, rpc.system.name, server.address, gcp.storage.operation, network.path).
  • StorageGrpcMetricsInterceptor: decode grpc-server-stats-bin payloads of at least 10 bytes (header bytes[0] == 0 && bytes[1] == 0, little-endian 8-byte nanosecond int64 at offset 2, negative values rejected, trailing fields ignored) and record server.duration on onClose, regardless of status. Intentionally gRPC-only.
  • Unit tests in StorageGrpcMetricsInterceptorTest covering valid, 0ns, trailing-field, short, wrong-prefix, negative, and missing trailers, plus non-OK status.

[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 adds support for tracking and recording server duration metrics within the gRPC client interceptor by decoding the grpc-server-stats-bin metadata trailer. It also includes comprehensive unit tests to validate the decoding logic and metric recording. The feedback suggests optimizing the decodeServerDurationSeconds method by manually decoding the little-endian byte array using bitwise operations instead of allocating a ByteBuffer on every gRPC call, which will reduce garbage collection pressure in this hot path.

@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

…erver-duration-metric

Resolve the StorageClientMetricsTest conflict by dropping the duplicated record*_recordsExact*
tests (recordServerDuration's exact 7-key coverage lives in StorageGrpcMetricsInterceptorTest).

[Generated-by: AI]
- decodeServerDurationSeconds accepts payloads of at least 10 bytes, still
  requiring the version/field-id header and reading the LE nanos at offset 2.
- Cover a 0ns trailer and a non-OK status in the server.duration test, assert
  its unit, and reuse createDebugInterceptor() in the request.active tests.

[Generated-by: AI]
@nidhiii-27
nidhiii-27 requested a review from cpriti-os November 26, 2026 06:05

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