Skip to content

feat(storage): wire logical operation metrics in Retrying and StorageOptions - #14695

Open
nidhiii-27 wants to merge 4 commits into
feat/storage-metrics-contextfrom
feat/storage-logical-metrics
Open

nidhiii-27 wants to merge 4 commits into
feat/storage-metrics-contextfrom
feat/storage-logical-metrics

Conversation

@nidhiii-27

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

Copy link
Copy Markdown
Contributor

Wires client-level metrics lifecycle and retrier operation metrics into StorageOptions and Retrying.

  • Initializes StorageClientMetrics provider and lifecycle management in StorageOptions.
  • Instruments Retrying to record operation attempts, durations, and status attributes.
  • Adds comprehensive unit tests (StorageOptionsTest, StorageClientMetricsTest, RetryingMetricsTest).

Stacked on #14728.

@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 OpenTelemetry metrics into the client-side retry mechanism of Google Cloud Storage. It updates StorageOptions, GrpcStorageOptions, and HttpStorageOptions to expose StorageClientMetrics, and modifies Retrying.DefaultRetrier to record attempts, errors, retries, operations, and duration metrics when metrics are enabled. Additionally, a comprehensive test suite RetryingMetricsTest has been added to verify metric collection across various retry scenarios. There are no review comments, and I have no feedback to provide.

@nidhiii-27
nidhiii-27 added this pull request to stack #14485 October 20, 2026 10:06
@nidhiii-27
nidhiii-27 force-pushed the feat/storage-metrics-context-error-mapping branch from 608c46a to 1bf9a9d Compare October 20, 2026 11:50
@nidhiii-27
nidhiii-27 force-pushed the feat/storage-logical-metrics branch from b385679 to 0a3696b Compare October 20, 2026 12:11
nidhiii-27 added a commit that referenced this pull request Oct 20, 2026
…options

- Narrow PR #14695 to core Retrying chokepoint and options wiring
- Remove per-run StorageMetricsContext binding from DefaultRetrierWithAlg to avoid elapsed time drift across runs
- Add createMetricsContext helper on StorageOptions
- Revert veneer operation wiring and server address attributes to separate stacked PR
- Update unit tests in RetryingMetricsTest

[Generated-by: AI]
@nidhiii-27
nidhiii-27 requested a review from cpriti-os October 21, 2026 17:56
@nidhiii-27
nidhiii-27 marked this pull request as ready for review October 22, 2026 05:02
@nidhiii-27
nidhiii-27 requested review from a team as code owners October 22, 2026 05:02
@Dhriti07
Dhriti07 force-pushed the feat/storage-logical-metrics branch from df24cde to 2455496 Compare October 22, 2026 05:06
@nidhiii-27
nidhiii-27 force-pushed the feat/storage-metrics-context-error-mapping branch from 98fb508 to 84a5ac6 Compare October 22, 2026 05:35
@nidhiii-27
nidhiii-27 requested review from a team as code owners October 22, 2026 05:35
@nidhiii-27
nidhiii-27 force-pushed the feat/storage-logical-metrics branch from 2455496 to 02b170e Compare October 22, 2026 05:42
@nidhiii-27
nidhiii-27 removed this pull request from stack #14485 October 22, 2026 05:45
@nidhiii-27
nidhiii-27 changed the base branch from feat/storage-metrics-context-error-mapping to feat/storage-metrics-context October 22, 2026 05:45
@nidhiii-27 nidhiii-27 changed the title feat(storage): wire logical operation metrics in Retrying chokepoint feat(storage): wire logical operation metrics in Retrying and StorageOptions Oct 22, 2026
@nidhiii-27
nidhiii-27 force-pushed the feat/storage-metrics-context branch from f943017 to edb3def Compare October 22, 2026 05:54
@nidhiii-27
nidhiii-27 force-pushed the feat/storage-logical-metrics branch from 02b170e to 2b123b7 Compare October 22, 2026 05:54
}

@Nullable
private SdkMeterProvider createDefaultClientMeterProvider() {

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.

Could we move createDefaultClientMeterProvider (and formatStorageEndpoint) into OpenTelemetryBootstrappingUtils?

StorageOptions is a public configuration/builder class (ServiceOptions), so it should ideally just hold user configuration and delegate initialization rather than containing ~80 lines of Cloud Monitoring exporter setup and endpoint string formatting.

Attributes detectedAttributes = resourceProvider.getAttributes();
String detectedProjectId = detectedAttributes.get(AttributeKey.stringKey("cloud.account.id"));
String configuredProjectId = getProjectId();
if (configuredProjectId != null && configuredProjectId.trim().isEmpty()) {

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.

In OpenTelemetryBootstrappingUtils.enableGrpcMetrics, detectedProjectId takes precedence over configuredProjectId (detectedProjectId == null ? projectId : detectedProjectId), whereas here configuredProjectId takes precedence over detectedProjectId. Is this difference intentional? If both are enabled on a gRPC client where getProjectId() differs from the compute environment's project, transport metrics and client metrics will be exported to different projects.

}

@Nullable
static String extractServerAddress(@Nullable String host) {

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.

Can we use Guava's HostAndPort.fromString(...) here instead of manually parsing colons and IPv6 brackets? Since formatStorageEndpoint above already strips the scheme (google-c2p:///, https://, http://), both methods could share a small helper that strips the scheme/path and returns a HostAndPort—then this is just .getHost() and formatStorageEndpoint is .withDefaultPort(443).toString().

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants