Repository navigation
feat(storage): add gcp.storage.client.ttfb metric - #14745
nidhiii-27 wants to merge 8 commits into
Conversation
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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]
…Context [Generated-by: AI]
….getBareMethodName() [Generated-by: AI]
cpriti-os
left a comment
There was a problem hiding this comment.
Implementation looks solid against the ttfb label set and measurement points. Left a couple of spec-scope questions and a nit inline.
…orage-ttfb-metric [Generated-by: AI]
[Generated-by: AI]
…tfb-metric [Generated-by: AI]
| // Evaluate isMediaDownloadRequest(request) at response time rather than in | ||
| // initialize(HttpRequest), because callers such as MediaHttpDownloader may append | ||
| // query parameters (e.g. alt=media) to request.getUrl() after buildGetRequest(). | ||
| if (recordTtfb && isMediaDownloadRequest(request)) { |
There was a problem hiding this comment.
gRPC now records ttfb for every RPC, while HTTP only records it for media downloads. Fine to keep this PR downloads-only — just checking HTTP unary/upload ttfb is tracked as a follow-up.
There was a problem hiding this comment.
Confirmed — keeping HTTP TTFB scoped to media downloads in this PR and raised #15066 for HTTP unary/upload TTFB (propagating operation names via StorageMetricsContext).
Co-authored by AI Agent
…etric - Merge updated feat/storage-http-request-duration (572ea33) and build StorageClientMetrics.recordTtfb directly from baseAttributes (rpc.system.name, server.address) - Re-anchor gRPC ttfbStartNanos only on write flush/finish (BidiWriteObjectRequest flush/finish_write and WriteObjectRequest finish_write) and drop Math.max - Map StartResumableWrite and QueryWriteStatus to WriteObject in package-private defaultOperationName - Drop redundant recordDuration/recordTtfb booleans across gRPC and HTTP interceptors - Record HTTP media-download TTFB inside StorageHttpMetricsInterceptor.recordResponse (excluding 401 token-refresh latency and synthetic batch responses) and update Javadoc - Consolidate HTTP and gRPC TTFB unit tests into existing cases with exact 7-attribute assertions and add defaultOperationName/isWriteFlush unit tests [Generated-by: AI]
Instruments gRPC and HTTP transports to record
gcp.storage.client.ttfb(time to first byte) OpenTelemetry histogram metrics.StorageGrpcMetricsInterceptor(anchored at call start for reads, unary RPCs, andopen(), and re-anchored atflush/finish_writefor writes; mapsBidiReadObjecttoReadObjectandBidiWriteObject,StartResumableWrite, andQueryWriteStatustoWriteObject) withrpc.system.name,gcp.storage.operation,network.path, andserver.addressattributes.StorageHttpMetricsInterceptor(HTTP unary/upload TTFB is tracked as a follow-up).StorageGrpcMetricsInterceptorTestandStorageHttpMetricsInterceptorTest.Stacked on #14744.