Repository navigation
feat(storage): add gcp.storage.client.request.body.size metric for write operations - #14746
nidhiii-27 wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces request body size tracking for 'WriteObject' operations in Google Cloud Storage by capturing and recording request bytes in the StorageMetricsContext. However, a critical compilation error was identified in GrpcStorageImpl.java where Files.size(path) is called outside of a try-catch block, throwing an unhandled checked IOException. Moving this call inside the try block will resolve the compilation issue and ensure proper exception handling.
There was a problem hiding this comment.
Code Review
This pull request implements tracking and recording of request body sizes for 'WriteObject' operations across various storage implementation classes, including BaseStorageWriteChannel, GrpcStorageImpl, and StorageImpl, using StorageMetricsContext. It also adds unit tests to verify this behavior. A review comment suggests moving the Files.size(path) call inside the try block in GrpcStorageImpl.java to ensure that any potential IOException is properly caught and handled by the existing error-handling logic.
…coverage - Move multiContext.setRequestBytes(Files.size(path)) inside the try block in GrpcStorageImpl.internalCreateFrom so IOExceptions from Files.size(path) are recorded on multiContext - Separate 3-arg StorageInternal.internalDirectUpload (PCU hook) from 4-arg internalDirectUpload in StorageImpl and GrpcStorageImpl to prevent PCU part upload double-counting - Instrument StorageImpl.create(BlobInfo, InputStream) and StorageImpl.internalCreateFrom(Path, BlobInfo, Opts) for dual-transport parity - Exclude HTTP-only and attempt/operation-only attributes in StorageMetricsContext.buildBodySizeAttributes - Expand StorageMetricsContextTest to cover BaseStorageWriteChannel, StorageImpl, and GrpcStorageImpl write paths [Generated-by: AI]
Summary
Implements the
gcp.storage.client.request.body.sizemetric forWriteObjectoperations across HTTP and gRPC transports.Changes
StorageMetricsContext:setRequestBytes(long)andaddRequestBytes(long)for tracking request payload size.gcp.storage.client.request.body.sizeinrecordOperation()whenoperationNameis"WriteObject"andrequestBytes > 0, filtering out attempt-only and HTTP-only attributes viabuildBodySizeAttributes(...).BaseStorageWriteChannel:metricsContextviaaddRequestBytes(write)duringwrite(ByteBuffer)and records once onclose().StorageImpl&GrpcStorageImpl:create(BlobInfo, ...)overloads (byte[],InputStream),createFrom(BlobInfo, Path, ...),createFrom(BlobInfo, InputStream, ...), andinternalCreateFrom(Path, BlobInfo, Opts<ObjectTargetOpt>)to record request payload size onWriteObjectmetrics contexts.StorageInternal.internalDirectUpload(BlobInfo, Opts<ObjectTargetOpt>, ByteBuffer)hook (used byParallelCompositeUploadWritableByteChannelpart uploads) from the private 4-argument helper so PCU part uploads do not double-countWriteObjectoperations or request body bytes.StorageMetricsContextTest:gcp.storage.client.request.body.sizerecording, attribute filtering (BODY_SIZE_EXCLUDED_KEYS), 0-byte and non-WriteObjectsuppression,BaseStorageWriteChannelwrite accumulation,StorageImplandGrpcStorageImplwrite entrypoints, and PCUinternalDirectUploadsuppression.