Skip to content

feat(storage): wire MetricsRecordingCredentials into HTTP and gRPC StorageOptions - #15234

Open
nidhiii-27 wants to merge 6 commits into
feat/storage-credential-refresh-wrapperfrom
feat/storage-credential-refresh-wiring
Open

nidhiii-27 wants to merge 6 commits into
feat/storage-credential-refresh-wrapperfrom
feat/storage-credential-refresh-wiring

Conversation

@nidhiii-27

Copy link
Copy Markdown
Contributor

Summary

Stacked on #15233.

Wires MetricsRecordingCredentials into HttpStorageOptions and GrpcStorageOptions when OpenTelemetry debug metrics are enabled, without mutating this.credentials or eagerly allocating an owned SdkMeterProvider when debug metrics are disabled.

Changes

  • HttpStorageOptions.getScopedCredentials(): gate on isEnableOtelDebugMetrics() before calling getStorageClientMetrics(), and wrap the returned scoped credentials via MetricsRecordingCredentials.wrap(...) without mutating this.credentials (preserving getCredentials(), ServiceAccountSigner, toBuilder(), equals(), hashCode(), and Serializable).
  • GrpcStorageOptions.resolveSettingsAndOpts(): gate on isEnableOtelDebugMetrics() and leave ComputeEngineCredentials unwrapped on gRPC so InstantiatingGrpcChannelProvider preserves DirectPath ALTS hard-bound tokens and EndpointContext skips unnecessary MDS universe domain lookups; wrap other credentials before the quota-project probe and QuotaProjectIdHidingCredentials.
  • Unit tests in MetricsRecordingCredentialsTest covering HTTP and gRPC wiring, debug-disabled passthrough, QuotaProjectIdHidingCredentials interaction, and gRPC ComputeEngineCredentials preservation.

[Generated-by: AI]

…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]
@nidhiii-27 nidhiii-27 added the ai-generated Pull Request generated by AI label Nov 25, 2026

@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 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]
@nidhiii-27
nidhiii-27 marked this pull request as ready for review November 26, 2026 06:05
@nidhiii-27
nidhiii-27 requested review from a team as code owners November 26, 2026 06:05
@nidhiii-27
nidhiii-27 requested review from Dhriti07 and cpriti-os and removed request for a team November 26, 2026 06:05
cpriti-os
cpriti-os previously approved these changes Nov 26, 2026

@cpriti-os cpriti-os 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.

Initial review

assertThat(httpDebugOptions.getCredentials()).isInstanceOf(ServiceAccountSigner.class);
assertThat(httpDebugOptions).isEqualTo(httpDebugOptionsCopy);
assertThat(httpDebugOptions.hashCode()).isEqualTo(httpDebugOptionsCopy.hashCode());
assertThat(httpDebugOptions.getScopedCredentials())

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.

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 =

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.

Nit: To verify that getScopedCredentials() does not initialize metrics when debug metrics are off, could we pass a MeterProvider that throws on meterBuilder here?

@cpriti-os
cpriti-os dismissed their stale review November 26, 2026 06:54

Initial review only — holding approval pending final pass

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.

2 participants