Repository navigation
feat(storage): OpenTelemetry client metrics configuration and options - #14484
nidhiii-27 wants to merge 6 commits into
Conversation
…ions [Generated-by: AI]
There was a problem hiding this comment.
Code Review
This pull request introduces OpenTelemetry client metrics configuration across GrpcStorageOptions, HttpStorageOptions, and StorageOptions, supported by a new StorageMetricsConfig class and comprehensive unit tests. The review feedback highlights critical issues regarding backward compatibility during deserialization, where the newly added metricInterval field could be null and cause a NullPointerException, and recommends declaring the static resolvers in StorageMetricsConfig as volatile to ensure thread safety during parallel test execution.
…rialization [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]
cpriti-os
left a comment
There was a problem hiding this comment.
Requesting changes mainly for serialization behaviour and the enablement configuration (see inline comments).
[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]
cpriti-os
left a comment
There was a problem hiding this comment.
LGTM once the getMeterProvider() default behavior below is addressed.
[Generated-by: AI]
Description
This PR implements Phase 2 (Configuration & Options API) of the OpenTelemetry Client Metrics feature in the Java Cloud Storage SDK (
google-cloud-storage), building on top of PR #14398 (feat/storage-client-metrics-infra).Key Changes
Public Options API (
StorageOptions,GrpcStorageOptions,HttpStorageOptions):isEnableOtelMetrics()(default:false)isEnableOtelDebugMetrics()(default:false)getMeterProvider()returningio.opentelemetry.api.metrics.MeterProvider(fromopentelemetry-api, avoiding leaking SDK implementation types in public API surface)getMetricInterval()(default: 60 seconds)@BetaApi:setEnableOtelMetrics(boolean)setEnableOtelDebugMetrics(boolean)setMeterProvider(MeterProvider)setMetricInterval(Duration)with precondition check requiring positive, non-zero durations.Feature Gates & Environment Variables (
StorageMetricsConfig):com.google.cloud.storage.enable_otel_metricscom.google.cloud.storage.enable_otel_debug_metricsGCP_STORAGE_JAVA_ENABLE_OTEL_METRICS(with fallback toGCP_STORAGE_ENABLE_OTEL_METRICS)GCP_STORAGE_JAVA_ENABLE_OTEL_DEBUG_METRICSfalse).Serialization Resiliency for Distributed Runtimes:
StorageOptionsis serialized across worker nodes:meterProvideras transient.readObject()to reconstitute fromopenTelemetry.getMeterProvider().getMeterProvider(), provided automatic fallback toopenTelemetry.getMeterProvider()whenmeterProvider == null.Testing:
StorageOptionsTest:IllegalArgumentExceptionon null, zero, or negative metric intervals.ByteArrayOutputStream/ObjectInputStream) ensuringgetMeterProvider()remains functional and non-null post-deserialization.[Generated-by: AI]