Skip to content

feat(storage): wire operation metrics in gRPC veneer - #14729

Open
nidhiii-27 wants to merge 101 commits into
mainfrom
feat/storage-grpc-veneer-operation-metrics
Open

nidhiii-27 wants to merge 101 commits into
mainfrom
feat/storage-grpc-veneer-operation-metrics

Conversation

@nidhiii-27

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

Copy link
Copy Markdown
Contributor

Wires operation metrics into the gRPC veneer implementation.

  • Instruments GrpcStorageImpl across unary calls, multi-step ACL operations, and streaming operations.
  • Plumbs metrics context into GapicCopyWriter, GrpcBlobReadChannel, and GrpcBlobWriteChannel.
  • Preserves StorageMetricsContext across inner withDefaultCallContext / GrpcCallContext.merge boundaries on WriteObject channels and sessions.
  • Updates TransformingPageDecorator.getNextPage() to check !hasNextPage() (returning null without invoking retrier.run) and route page 2+ through the bound retrier so pagination attempts are recorded under the ListBuckets metrics context (per earlier review comment r4432540827).
  • Verifies operation tracking with unit tests.

Stacked on #14698.

…nfiguration

- Add configuration options to StorageOptions, GrpcStorageOptions, and HttpStorageOptions (enableOtelMetrics, enableOtelDebugMetrics, meterProvider, metricInterval).
- Add development gate checking system properties and environment variables in StorageMetricsConfig.
- Implement package-private instrument registry in StorageClientMetrics.
- Update OpenTelemetryBootstrappingUtils to register client views with custom histogram boundaries and create client meter provider.
- Add comprehensive unit tests in StorageOptionsTest, StorageClientMetricsTest, and OpenTelemetryBootstrappingUtilsTest.
Apply spotify fmt-maven-plugin formatting to StorageMetricsConfig, StorageClientMetrics, StorageOptionsTest, and StorageClientMetricsTest.

[Generated-by: AI]
Use simple class name Duration instead of fully qualified java.time.Duration in GrpcStorageOptions and OpenTelemetryBootstrappingUtils.

[Generated-by: AI]
…trappingUtils

Apply spotify fmt-maven-plugin formatting to OpenTelemetryBootstrappingUtils.

[Generated-by: AI]
… metrics

Refactor addClientHistogramView in OpenTelemetryBootstrappingUtils to remove unit selector and custom view description, preserving instrument default descriptions.

Remove deferred Phase 2 connection metrics (dnsLookupDuration, tcpConnectDuration, tlsHandshakeDuration) from StorageClientMetrics, CLIENT_LATENCY_HISTOGRAMS, and StorageClientMetricsTest.

Ensure clean Duration imports.

[Generated-by: AI]
…rProvider

Default api parameter to "grpc" instead of "storage" in createClientMeterProvider, allow specifying "json" / "http" transport protocols for Cloud Monitoring monitored resource storage.googleapis.com/Client, and add unit test coverage in OpenTelemetryBootstrappingUtilsTest.

[Generated-by: AI]
Update createClientMeterProvider to use prefix custom.googleapis.com with default monitored resource mapping.
Add KEY_URL_TEMPLATE attribute key constant in StorageClientMetrics.

[Generated-by: AI]
… options

- In GrpcStorageOptions and HttpStorageOptions:
  - Add null check in getMetricInterval() defaulting to 60 seconds
  - Use getMetricInterval() in equals() and hashCode()
  - Update Javadoc for setMeterProvider to document nullable/default behavior
- In StorageOptions:
  - Update Javadoc for setMeterProvider on Builder
- In StorageMetricsConfig:
  - Make sysPropResolver and envResolver volatile for thread safety
- In StorageOptionsTest:
  - Add unit test verifying deserialization with null metricInterval defaults to 60s and equals/hashCode match
  - Verify explicit client options take precedence over env vars and sysprops

[Generated-by: AI]
Format StorageOptions, GrpcStorageOptions, HttpStorageOptions, and StorageOptionsTest using com.spotify.fmt:fmt-maven-plugin:2.25:format under JDK 17 to resolve CI lint check failure.

[Generated-by: AI]
…iew comments

Clamp metric export interval to at least 60 seconds when meterProvider is null and no custom OpenTelemetry is configured, preventing invalid sub-60s intervals during deserialization when falling back to default Cloud Monitoring exporter.

[Generated-by: AI]
…ig and tests

Deduplicate flag resolution in StorageMetricsConfig by extracting resolveFlag helper, separate multi-behavior tests per go/tott/726, and add input diagnostic messages in looped assertions.

[Generated-by: AI]
@nidhiii-27
nidhiii-27 requested review from a team as code owners October 22, 2026 05:52
nidhiii-27 and others added 16 commits November 9, 2026 07:38
…/storage-grpc-veneer-operation-metrics

[Generated-by: AI]
…edundant createContext fallbacks

[Generated-by: AI]
…e-grpc-veneer-operation-metrics

[Generated-by: AI]
Base automatically changed from feat/storage-veneer-operation-metrics to main November 16, 2026 11:43
- Extract readToChannel helper in GrpcStorageImpl for readAllBytes and both downloadTo overloads, coalescing IOException to StorageException before recording error metrics and catching Throwable
- Catch Throwable in multi-step ACL methods in GrpcStorageImpl
- Preserve StorageMetricsContext across inner withDefaultCallContext/GrpcCallContext.merge calls in WriteObject paths
- Remove redundant chunkContext alias in GapicCopyWriter and rename subAttemptContext to callContext
- Split multi-behavior tests in GrpcStorageImplTest and add tests for last-page getNextPage(), IOException-wrapped StorageException, and WriteObject context propagation
…est for Java 8 compatibility

Replace Mockito.mock(StreamController.class) with TestUtils.nullStreamController()
in stubMidStreamReadFailure to avoid ByteBuddy JDK 8 failures when copying JSpecify
@NullMarked annotations from StreamController.

[Generated-by: AI]
@nidhiii-27 nidhiii-27 added ai-generated Pull Request generated by AI kokoro:force-run Add this label to force Kokoro to re-run the tests. labels Dec 4, 2026
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Dec 4, 2026
nidhiii-27 added a commit that referenced this pull request Dec 4, 2026
Pull in cdca421 (from feat/storage-grpc-veneer-operation-metrics / #14729) to replace Mockito.mock(StreamController.class) with TestUtils.nullStreamController() in GrpcStorageImplTest for JDK 8 compatibility.

[Generated-by: AI]
nidhiii-27 added a commit that referenced this pull request Dec 4, 2026
Bring in the Java 8 compatibility fix for GrpcStorageImplTest (TestUtils.nullStreamController() instead of Mockito.mock(StreamController.class)) from feat/storage-grpc-veneer-operation-metrics (#14729).

[Generated-by: AI]
nidhiii-27 added a commit that referenced this pull request Dec 4, 2026
Pull in cdca421 (from feat/storage-grpc-veneer-operation-metrics / #14729) to replace Mockito.mock(StreamController.class) with TestUtils.nullStreamController() in GrpcStorageImplTest for JDK 8 compatibility.

[Generated-by: AI]
nidhiii-27 added a commit that referenced this pull request Dec 4, 2026
Pull in cdca421 (from feat/storage-grpc-veneer-operation-metrics / #14729) to replace Mockito.mock(StreamController.class) with TestUtils.nullStreamController() in GrpcStorageImplTest for JDK 8 compatibility.

[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

ai-generated Pull Request generated by AI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants