Repository navigation
feat(storage): wire MetricsRecordingCredentials into HTTP and gRPC StorageOptions - #15234
nidhiii-27 wants to merge 6 commits into
Conversation
…orageOptions Wire MetricsRecordingCredentials into HttpStorageOptions.getScopedCredentials() and GrpcStorageOptions.resolveSettingsAndOpts() when OpenTelemetry debug metrics are enabled, without mutating this.credentials or eagerly allocating an owned SdkMeterProvider when debug metrics are off. Preserve unwrapped ComputeEngineCredentials on gRPC for DirectPath ALTS bound tokens and EndpointContext universe domain validation. [Generated-by: AI]
There was a problem hiding this comment.
Code Review
This pull request updates GrpcStorageOptions and HttpStorageOptions to wrap credentials in MetricsRecordingCredentials when OpenTelemetry debug metrics are enabled, while keeping ComputeEngineCredentials unwrapped on gRPC to preserve DirectPath ALTS hard-bound tokens. Comprehensive unit tests are added to verify these behaviors. The review feedback highlights potential NullPointerException risks in both options if the credentials are null, suggesting defensive null checks before wrapping.
…age-credential-refresh-wiring [Generated-by: AI]
Merge feat/storage-credential-refresh-wrapper (26a80d4) and replace mock(ComputeEngineCredentials.class) in grpcStorageOptions_wiresCredentialsWithoutMutating with a real ComputeEngineCredentials instance carrying a pre-populated AccessToken. In google-auth-library 1.58.0, JSpecify @NullMarked (whose @target includes ElementType.MODULE) causes ByteBuddy annotation inspection to throw ArrayStoreException on JDK 8. [Generated-by: AI]
…age-credential-refresh-wiring [Generated-by: AI]
…age-credential-refresh-wiring [Generated-by: AI]
…age-credential-refresh-wiring [Generated-by: AI]
| assertThat(httpDebugOptions.getCredentials()).isInstanceOf(ServiceAccountSigner.class); | ||
| assertThat(httpDebugOptions).isEqualTo(httpDebugOptionsCopy); | ||
| assertThat(httpDebugOptions.hashCode()).isEqualTo(httpDebugOptionsCopy.hashCode()); | ||
| assertThat(httpDebugOptions.getScopedCredentials()) |
There was a problem hiding this comment.
Nit: Can we also set fakeClock and trigger a refresh on httpDebugOptions.getScopedCredentials() here to verify the duration metric is recorded end-to-end?
| .isInstanceOf(MetricsRecordingCredentials.class); | ||
|
|
||
| // Toggling debug off via toBuilder() yields unwrapped credentials without leaking a wrapper. | ||
| HttpStorageOptions httpStdOptions = |
There was a problem hiding this comment.
Nit: To verify that getScopedCredentials() does not initialize metrics when debug metrics are off, could we pass a MeterProvider that throws on meterBuilder here?
Initial review only — holding approval pending final pass
Summary
Stacked on #15233.
Wires
MetricsRecordingCredentialsintoHttpStorageOptionsandGrpcStorageOptionswhen OpenTelemetry debug metrics are enabled, without mutatingthis.credentialsor eagerly allocating an ownedSdkMeterProviderwhen debug metrics are disabled.Changes
HttpStorageOptions.getScopedCredentials(): gate onisEnableOtelDebugMetrics()before callinggetStorageClientMetrics(), and wrap the returned scoped credentials viaMetricsRecordingCredentials.wrap(...)without mutatingthis.credentials(preservinggetCredentials(),ServiceAccountSigner,toBuilder(),equals(),hashCode(), andSerializable).GrpcStorageOptions.resolveSettingsAndOpts(): gate onisEnableOtelDebugMetrics()and leaveComputeEngineCredentialsunwrapped on gRPC soInstantiatingGrpcChannelProviderpreserves DirectPath ALTS hard-bound tokens andEndpointContextskips unnecessary MDS universe domain lookups; wrap other credentials before the quota-project probe andQuotaProjectIdHidingCredentials.MetricsRecordingCredentialsTestcovering HTTP and gRPC wiring, debug-disabled passthrough,QuotaProjectIdHidingCredentialsinteraction, and gRPCComputeEngineCredentialspreservation.[Generated-by: AI]