Skip to content

feat(storage): OpenTelemetry client metrics infrastructure and configuration - #14398

Open
nidhiii-27 wants to merge 4 commits into
mainfrom
feat/storage-client-metrics-infra
Open

nidhiii-27 wants to merge 4 commits into
mainfrom
feat/storage-client-metrics-infra

Conversation

@nidhiii-27

Copy link
Copy Markdown
Contributor

Description

This PR implements PR 1 of the OpenTelemetry Client Metrics feature in the Java Cloud Storage SDK (google-cloud-storage).

Key Changes

  1. Configuration & Development Gate:

    • Added configuration options to StorageOptions (and GrpcStorageOptions, HttpStorageOptions):
      • isEnableOtelMetrics() (default: false)
      • isEnableOtelDebugMetrics() (default: false)
      • getMeterProvider() (default: null)
      • getMetricInterval() (default: Duration.ofSeconds(60))
      • Corresponding builder methods annotated with @BetaApi.
    • Added StorageMetricsConfig development gate checking system properties:
      • com.google.cloud.storage.enable_otel_metrics
      • com.google.cloud.storage.enable_otel_debug_metrics
        and environment variables:
      • GCP_STORAGE_JAVA_ENABLE_OTEL_METRICS (with fallback GCP_STORAGE_ENABLE_OTEL_METRICS)
      • GCP_STORAGE_JAVA_ENABLE_OTEL_DEBUG_METRICS
  2. Instrument Registry:

    • Created package-private StorageClientMetrics registry holding all standard and debug instruments with exact OpenTelemetry specification names and units.
  3. OpenTelemetry Bootstrapping:

    • Updated OpenTelemetryBootstrappingUtils:
      • Registered custom histogram boundaries for client metrics (latencyHistogramBoundaries and sizeHistogramBoundaries).
      • Added createClientMeterProvider with "storage.googleapis.com/Client" monitored resource.
  4. Testing:

    • Added comprehensive unit tests in StorageOptionsTest, StorageClientMetricsTest, and updated OpenTelemetryBootstrappingUtilsTest.

…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.
@nidhiii-27
nidhiii-27 requested review from a team as code owners September 16, 2026 09:21

@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 introduces OpenTelemetry client metrics support for Google Cloud Storage, allowing standard and debug metrics to be configured and recorded for both HTTP and gRPC transports. It adds configuration options to StorageOptions, GrpcStorageOptions, and HttpStorageOptions for enabling metrics, setting custom meter providers, and defining export intervals, supported by a new StorageMetricsConfig utility and StorageClientMetrics registry. Feedback on the changes suggests importing java.time.Duration to avoid using fully qualified class names throughout GrpcStorageOptions.java and OpenTelemetryBootstrappingUtils.java, which will improve code readability and consistency.

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]
@nidhiii-27 nidhiii-27 added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Sep 16, 2026
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Sep 16, 2026
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.

2 participants