Skip to content

feat(storage): wire veneer operation metrics in StorageImpl and GrpcStorageImpl - #14698

Open
nidhiii-27 wants to merge 4 commits into
feat/storage-logical-metricsfrom
feat/storage-veneer-operation-metrics
Open

nidhiii-27 wants to merge 4 commits into
feat/storage-logical-metricsfrom
feat/storage-veneer-operation-metrics

Conversation

@nidhiii-27

Copy link
Copy Markdown
Contributor

Description

This PR is stacked on top of #14695 (feat/storage-logical-metrics).
It wires operation-level metrics context across GrpcStorageImpl (gRPC transport), StorageImpl (HTTP transport), and GapicCopyWriter, matching the exact Go SDK / HLD PascalCase operation names (google-cloud-go/storage/metrics.go:1319–1580).

Summary of Changes:

  • GapicCopyWriter.java:
    • Attached "RewriteObject" StorageMetricsContext to Retrying.newCallContext(metricsContext) and passed to retrier.run(...) during chunk copy iterations.
  • GrpcStorageImpl.java:
    • Explicitly merged GrpcCallContext with Retrying.newCallContext(metricsContext) across all unary and non-streaming call sites (getOptions().createMetricsContext("<OperationName>")).
    • Updated TransformingPageDecorator to accept a Supplier<StorageMetricsContext> and supply fresh metrics context on iterateAll().
    • Wired ListObjectsWithSyntheticDirectoriesPage.getNextPage() with "ListObjects" metrics context.
    • Left streaming channel methods untouched (reserved for follow-up PR).
  • StorageImpl.java:
    • Replaced 3-arg run(...) with 4-arg run(String operationName, ResultRetryAlgorithm<?> algorithm, Callable<T> c, Decoder<T, U> f) mapping to getOptions().createMetricsContext(operationName).
    • Wired all operations including Buckets, Objects, IAM policies, Bucket/Object ACLs, HMAC keys, and Notifications.
    • Passed metrics contexts in static page fetchers (listBuckets, listBlobs, listHmacKeys).
    • Left streaming channel methods untouched.

[Generated-by: AI]

…torageImpl

- Wire operation-level metrics context across GrpcStorageImpl and StorageImpl
- Wire RewriteObject metrics context in GapicCopyWriter.copyChunk()
- Map operation names matching Go SDK / HLD PascalCase specification (CreateBucket, ListBuckets, GetBucket, UpdateBucket, DeleteBucket, LockBucketRetentionPolicy, ListObjects, GetObject, UpdateObject, DeleteObject, RestoreObject, ComposeObject, RewriteObject, MoveObject, WriteObject, ReadObject, GetIamPolicy, SetIamPolicy, TestIamPermissions, GetServiceAccount, CreateHMACKey, GetHMACKey, ListHMACKeys, UpdateHMACKey, DeleteHMACKey, CreateNotification, GetNotification, ListNotifications, DeleteNotification, GetBucketACL, DeleteBucketACL, CreateBucketACL, UpdateBucketACL, ListBucketACLs, GetDefaultObjectACL, DeleteDefaultObjectACL, CreateDefaultObjectACL, UpdateDefaultObjectACL, ListDefaultObjectACLs, GetObjectACL, DeleteObjectACL, CreateObjectACL, UpdateObjectACL, ListObjectACLs)
- Explicitly merge GrpcCallContext with Retrying.newCallContext(metricsContext) across all unary/call sites in GrpcStorageImpl without wrapper helpers
- Supply metrics context in pagination decorators (TransformingPageDecorator, ListObjectsWithSyntheticDirectoriesPage, ListBucketsWithPartialSuccessPage)
- Leave streaming channel methods untouched for follow-up PR

[Generated-by: AI]
@nidhiii-27
nidhiii-27 requested review from a team as code owners October 20, 2026 14:05

@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 integrates StorageMetricsContext across various storage operations in GrpcStorageImpl, StorageImpl, and GapicCopyWriter to enable operation-specific metrics tracking. However, in GrpcStorageImpl.java's moveBlob method, the metricsContext is passed to the retrier but is not merged into the GrpcCallContext or passed to the moveObjectCallable call, which prevents proper propagation of the metrics context to the gRPC request.

Comment on lines +1494 to +1499
StorageMetricsContext metricsContext = getOptions().createMetricsContext("MoveObject");
return retrier.run(
retryAlgorithmManager.getFor(req),
() -> storageClient.moveObjectCallable().call(req),
syntaxDecoders.blob);
syntaxDecoders.blob,
metricsContext);

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.

high

In moveBlob, the metricsContext is created and passed to retrier.run, but it is not merged into the GrpcCallContext and passed to storageClient.moveObjectCallable().call(req). This means the metrics context will not be propagated to the actual gRPC request headers/metadata. We should merge grpcCallContext with Retrying.newCallContext(metricsContext) and pass the merged context to the callable, matching the pattern used in all other methods in this class.

    StorageMetricsContext metricsContext = getOptions().createMetricsContext("MoveObject");
    GrpcCallContext merge = Utils.merge(grpcCallContext, Retrying.newCallContext(metricsContext));
    return retrier.run(
        retryAlgorithmManager.getFor(req),
        () -> storageClient.moveObjectCallable().call(req, merge),
        syntaxDecoders.blob,
        metricsContext);

- Pass serviceOptions.createMetricsContext("RewriteObject") in copyChunk()
- Use serviceOptions.asRetryDependencies() in StateImpl.restore()
- Add test in CopyWriterTest to verify RewriteObject metrics context is passed

[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