Skip to content

feat(storage): add gcp.storage.client.ttfb metric for read operations - #14745

Draft
nidhiii-27 wants to merge 2 commits into
feat/storage-http-request-durationfrom
feat/storage-ttfb-metric
Draft

nidhiii-27 wants to merge 2 commits into
feat/storage-http-request-durationfrom
feat/storage-ttfb-metric

Conversation

@nidhiii-27

@nidhiii-27 nidhiii-27 commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Instruments read operations across gRPC and HTTP transports to record gcp.storage.client.ttfb (time to first byte) OpenTelemetry histogram metrics.

  • Records time from RPC start to first response message on ReadObject and BidiReadObject in StorageGrpcMetricsInterceptor with rpc.system.name, gcp.storage.operation (ReadObject), network.path, and server.address attributes.
  • Records time from request execution to 2xx response headers on media download requests in StorageHttpMetricsInterceptor.
  • Adds unit tests in StorageGrpcMetricsInterceptorTest and StorageHttpMetricsInterceptorTest.

Stacked on #14744.

@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 Time to First Byte (TTFB) metrics tracking for both gRPC and HTTP storage clients, along with corresponding unit tests. The feedback highlights a potential NullPointerException in StorageGrpcMetricsInterceptor due to a missing null check in onClose when rpcClientCallDuration is null, and suggests restricting HTTP TTFB recording to 2xx status codes to prevent misleading metrics on 3xx responses.

@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 Time to First Byte (TTFB) metrics tracking for both gRPC and HTTP Google Cloud Storage clients, along with comprehensive unit tests. The feedback highlights a potential NullPointerException in the gRPC interceptor if call duration metrics are disabled while TTFB is enabled, and suggests a refactoring to safely guard against this. Additionally, an optimization is suggested for the HTTP interceptor to avoid registering response interceptors when no metrics need to be recorded.

…ceptor checks

Use KEY_GCP_STORAGE_OPERATION (ReadObject) for gcp.storage.client.ttfb across gRPC and HTTP interceptors, restrict HTTP TTFB recording to 2xx status codes, hoist recordDuration/recordTtfb checks, and expand unit test coverage.

[Generated-by: AI]

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant