GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(storage): OpenTelemetry client metrics configuration and options by nidhiii-27 · Pull Request #14484 · googleapis/google-cloud-java

feat(storage): OpenTelemetry client metrics configuration and options #14484

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
nidhiii-27 merged 29 commits into main from feat/storage-client-metrics-config
Oct 27, 2026

Uh oh!

There was an error while loading. Please reload this page.

Merged

feat(storage): OpenTelemetry client metrics configuration and options #14484

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
07f72be
feat(storage): add OpenTelemetry client metrics infrastructure and co…
nidhiii-27 Sep 16, 2026
235a230
fix(storage): resolve code formatting violations for client metrics
nidhiii-27 Sep 16, 2026
590ad9e
fix(storage): resolve PR review comments on OpenTelemetry metrics
nidhiii-27 Sep 16, 2026
02a7740
fix(storage): resolve code formatting violation in OpenTelemetryBoots…
nidhiii-27 Sep 16, 2026
f686723
feat(storage): add OpenTelemetry client metrics instrument registry a…
nidhiii-27 Sep 23, 2026
babb702
fix(storage): refactor histogram views and remove deferred connection…
nidhiii-27 Sep 30, 2026
22a233f
fix(storage): support transport-derived api label in createClientMete…
nidhiii-27 Oct 7, 2026
1f2c146
fix(storage): address review comments for OpenTelemetry client metrics
nidhiii-27 Oct 8, 2026
7828fd2
feat(storage): address review feedback on client metrics infra
nidhiii-27 Oct 14, 2026
983f248
style(storage): format code with fmt-maven-plugin
nidhiii-27 Oct 14, 2026
52cd16a
refactor(storage): address PR review comments for OpenTelemetry clien…
nidhiii-27 Oct 16, 2026
18b1e73
fix(storage): resolve review comments for client metrics infra
nidhiii-27 Oct 19, 2026
6e7a5c6
refactor(storage): preserve detectedAttributes in buildMeterProvider …
nidhiii-27 Oct 19, 2026
57fa64a
fix(metrics): update metric counter units to match Go SDK and design doc
nidhiii-27 Oct 20, 2026
f39f525
test(storage): deduplicate instrument nullability assertions in Stora…
nidhiii-27 Oct 20, 2026
a1f434d
test(storage): initialize InMemoryMetricReader in @Before and clean u…
nidhiii-27 Oct 20, 2026
4607b23
refactor(storage): remove misleading @VisibleForTesting from histogra…
nidhiii-27 Oct 20, 2026
97ed050
refactor(storage): remove gcp.storage.client.retries counter [Generat…
nidhiii-27 Oct 21, 2026
dc20d62
feat(storage): add OpenTelemetry client metrics configuration and opt…
nidhiii-27 Sep 23, 2026
07dcbb1
fix(storage): preserve meterProvider equality across toBuilder and se…
nidhiii-27 Sep 23, 2026
434948f
fix(storage): add deserialization guard for metricInterval and update…
nidhiii-27 Sep 30, 2026
327b558
fix(storage): address PR review comments for otel metrics config
nidhiii-27 Oct 8, 2026
517e61f
style(storage): format StorageOptions classes with fmt-maven-plugin
nidhiii-27 Oct 8, 2026
7f624a2
fix(storage): address review comments on otel metrics config
nidhiii-27 Oct 15, 2026
4f4f726
fix(storage): clamp metricInterval on deserialization and resolve rev…
nidhiii-27 Oct 19, 2026
9519e62
refactor(storage): address PR review comments for client metrics conf…
nidhiii-27 Oct 19, 2026
3d889a7
fix(storage): address review comments on PR #14484 for metrics option…
nidhiii-27 Oct 20, 2026
e7a3588
test(storage): deduplicate HTTP and gRPC test cases in StorageOptions…
nidhiii-27 Oct 20, 2026
eed0d13
Merge branch 'main' into feat/storage-client-metrics-config
nidhiii-27 Oct 26, 2026
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

There are no files selected for viewing

68 changes: 68 additions & 0 deletions 68 ...orage/google-cloud-storage/src/main/java/com/google/cloud/storage/GrpcStorageOptions.java
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
import io.grpc.StatusRuntimeException;
import io.grpc.protobuf.ProtoUtils;
import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.api.metrics.MeterProvider;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
Expand All @@ -122,6 +123,7 @@
import java.util.concurrent.ScheduledExecutorService;
import java.util.logging.Logger;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;

/**
* @since 2.14.0
Expand Down Expand Up @@ -432,6 +434,10 @@ public int hashCode() {
grpcInterceptorProvider,
blobWriteSessionConfig,
openTelemetry,
isEnableOtelMetrics(),
isEnableOtelDebugMetrics(),
getMeterProvider(),
getMetricInterval(),
baseHashCode());
}

Expand All @@ -446,11 +452,15 @@ public boolean equals(Object o) {
GrpcStorageOptions that = (GrpcStorageOptions) o;
return attemptDirectPath == that.attemptDirectPath
&& enableGrpcClientMetrics == that.enableGrpcClientMetrics
&& isEnableOtelMetrics() == that.isEnableOtelMetrics()
&& isEnableOtelDebugMetrics() == that.isEnableOtelDebugMetrics()
&& Objects.equals(retryAlgorithmManager, that.retryAlgorithmManager)
&& Objects.equals(terminationAwaitDuration, that.terminationAwaitDuration)
&& Objects.equals(grpcInterceptorProvider, that.grpcInterceptorProvider)
&& Objects.equals(blobWriteSessionConfig, that.blobWriteSessionConfig)
&& Objects.equals(openTelemetry, that.openTelemetry)
&& Objects.equals(getMeterProvider(), that.getMeterProvider())
&& Objects.equals(getMetricInterval(), that.getMetricInterval())
&& this.baseEquals(that);
}

Expand Down Expand Up @@ -747,6 +757,64 @@ public GrpcStorageOptions.Builder setApiTracerFactory(ApiTracerFactory apiTracer
public GrpcStorageOptions.Builder setOpenTelemetry(OpenTelemetry openTelemetry) {
requireNonNull(openTelemetry, "openTelemetry must be non null");
this.openTelemetry = openTelemetry;
setCustomOpenTelemetryConfigured(true);
return this;
}

/**
* Enable or disable OpenTelemetry client metrics.
*
* @param enableOtelMetrics whether OpenTelemetry client metrics should be enabled
* @since 2.76.0 This new api is in preview and is subject to breaking changes.
*/
@BetaApi
@Override
public GrpcStorageOptions.Builder setEnableOtelMetrics(boolean enableOtelMetrics) {
super.setEnableOtelMetrics(enableOtelMetrics);
return this;
}

/**
* Enable or disable OpenTelemetry debug client metrics.
*
* @param enableOtelDebugMetrics whether OpenTelemetry debug client metrics should be enabled
* @since 2.76.0 This new api is in preview and is subject to breaking changes.
*/
@BetaApi
@Override
public GrpcStorageOptions.Builder setEnableOtelDebugMetrics(boolean enableOtelDebugMetrics) {
super.setEnableOtelDebugMetrics(enableOtelDebugMetrics);
return this;
}

/**
* Set a custom {@link MeterProvider} for recording client metrics.
*
* @param meterProvider custom MeterProvider to use, or null to use the default
* @since 2.76.0 This new api is in preview and is subject to breaking changes.
*/
@BetaApi
@Override
public GrpcStorageOptions.Builder setMeterProvider(@Nullable MeterProvider meterProvider) {
super.setMeterProvider(meterProvider);
return this;
}

/**
* Set the metric export interval for periodic metric reading.
*
* <p>When using the default Cloud Monitoring exporter, the interval must be at least 60 seconds
* (1 minute). Intervals less than 60 seconds are permitted only when a custom {@link
* MeterProvider} is configured via {@link #setMeterProvider(MeterProvider)} or explicit
* OpenTelemetry is configured via {@link #setOpenTelemetry(OpenTelemetry)}.
*
* @param metricInterval interval duration
* @since 2.76.0 This new api is in preview and is subject to breaking changes.
*/
@BetaApi
@Override
public GrpcStorageOptions.Builder setMetricInterval(Duration metricInterval) {
Comment thread
nidhiii-27 marked this conversation as resolved.
Resolved

Uh oh!

There was an error while loading. Please reload this page.

super.setMetricInterval(metricInterval);
return this;
}

Expand Down
74 changes: 73 additions & 1 deletion 74 ...orage/google-cloud-storage/src/main/java/com/google/cloud/storage/HttpStorageOptions.java
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,16 @@
import com.google.common.base.MoreObjects;
import com.google.common.collect.ImmutableSet;
import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.api.metrics.MeterProvider;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.Serializable;
import java.time.Clock;
import java.time.Duration;
import java.util.Objects;
import java.util.Set;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;

/**
* @since 2.14.0
Expand Down Expand Up @@ -110,7 +113,14 @@ public HttpStorageOptions.Builder toBuilder() {
@Override
public int hashCode() {
return Objects.hash(
retryAlgorithmManager, blobWriteSessionConfig, openTelemetry, baseHashCode());
retryAlgorithmManager,
blobWriteSessionConfig,
openTelemetry,
isEnableOtelMetrics(),
isEnableOtelDebugMetrics(),
getMeterProvider(),
getMetricInterval(),
baseHashCode());
}

@Override
Expand All @@ -125,6 +135,10 @@ public boolean equals(Object o) {
return Objects.equals(retryAlgorithmManager, that.retryAlgorithmManager)
&& Objects.equals(blobWriteSessionConfig, that.blobWriteSessionConfig)
&& Objects.equals(openTelemetry, that.openTelemetry)
&& isEnableOtelMetrics() == that.isEnableOtelMetrics()
&& isEnableOtelDebugMetrics() == that.isEnableOtelDebugMetrics()
&& Objects.equals(getMeterProvider(), that.getMeterProvider())
&& Objects.equals(getMetricInterval(), that.getMetricInterval())
&& this.baseEquals(that);
}

Expand Down Expand Up @@ -315,6 +329,64 @@ public HttpStorageOptions build() {
public HttpStorageOptions.Builder setOpenTelemetry(OpenTelemetry openTelemetry) {
requireNonNull(openTelemetry, "openTelemetry must be non null");
this.openTelemetry = openTelemetry;
setCustomOpenTelemetryConfigured(true);
return this;
}

/**
* Enable or disable OpenTelemetry client metrics.
*
* @param enableOtelMetrics whether OpenTelemetry client metrics should be enabled
* @since 2.76.0 This new api is in preview and is subject to breaking changes.
*/
@BetaApi
@Override
public HttpStorageOptions.Builder setEnableOtelMetrics(boolean enableOtelMetrics) {
super.setEnableOtelMetrics(enableOtelMetrics);
return this;
}

/**
* Enable or disable OpenTelemetry debug client metrics.
*
* @param enableOtelDebugMetrics whether OpenTelemetry debug client metrics should be enabled
* @since 2.76.0 This new api is in preview and is subject to breaking changes.
*/
@BetaApi
@Override
public HttpStorageOptions.Builder setEnableOtelDebugMetrics(boolean enableOtelDebugMetrics) {
super.setEnableOtelDebugMetrics(enableOtelDebugMetrics);
return this;
}

/**
* Set a custom {@link MeterProvider} for recording client metrics.
*
* @param meterProvider custom MeterProvider to use, or null to use the default
* @since 2.76.0 This new api is in preview and is subject to breaking changes.
*/
@BetaApi
@Override
public HttpStorageOptions.Builder setMeterProvider(@Nullable MeterProvider meterProvider) {
super.setMeterProvider(meterProvider);
return this;
}

/**
* Set the metric export interval for periodic metric reading.
*
* <p>When using the default Cloud Monitoring exporter, the interval must be at least 60 seconds
* (1 minute). Intervals less than 60 seconds are permitted only when a custom {@link
* MeterProvider} is configured via {@link #setMeterProvider(MeterProvider)} or explicit
* OpenTelemetry is configured via {@link #setOpenTelemetry(OpenTelemetry)}.
*
* @param metricInterval interval duration
* @since 2.76.0 This new api is in preview and is subject to breaking changes.
*/
@BetaApi
@Override
public HttpStorageOptions.Builder setMetricInterval(Duration metricInterval) {
super.setMetricInterval(metricInterval);
return this;
}
}
Expand Down
112 changes: 112 additions & 0 deletions 112 ...age/google-cloud-storage/src/main/java/com/google/cloud/storage/StorageMetricsConfig.java
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
/*
* Copyright 2026 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.google.cloud.storage;

import com.google.common.annotations.VisibleForTesting;
import java.util.Locale;
import java.util.function.Function;
import java.util.logging.Logger;
import org.checkerframework.checker.nullness.qual.Nullable;

final class StorageMetricsConfig {
private static final Logger LOGGER = Logger.getLogger(StorageMetricsConfig.class.getName());

static final String ENV_ENABLE_OTEL_METRICS_JAVA = "GCP_STORAGE_JAVA_ENABLE_OTEL_METRICS";
static final String ENV_ENABLE_OTEL_DEBUG_METRICS = "GCP_STORAGE_JAVA_ENABLE_OTEL_DEBUG_METRICS";

private static volatile Function<String, String> envResolver = System::getenv;

private StorageMetricsConfig() {}

static boolean isEnableOtelMetrics() {
return isEnableOtelMetrics(null);
}

static boolean isEnableOtelDebugMetrics() {
return isEnableOtelDebugMetrics(null);
}

static boolean isEnableOtelMetrics(@Nullable Boolean builderSetting) {
return isEnableOtelMetrics(envResolver, builderSetting);
}

static boolean isEnableOtelDebugMetrics(@Nullable Boolean builderSetting) {
return isEnableOtelDebugMetrics(envResolver, builderSetting);
}

@VisibleForTesting
Comment thread
nidhiii-27 marked this conversation as resolved.
Resolved

Uh oh!

There was an error while loading. Please reload this page.

static boolean isEnableOtelMetrics(
Function<String, String> env, @Nullable Boolean builderSetting) {
return resolveFlag(env, builderSetting, ENV_ENABLE_OTEL_METRICS_JAVA);
}

@VisibleForTesting
static boolean isEnableOtelDebugMetrics(
Function<String, String> env, @Nullable Boolean builderSetting) {
return resolveFlag(env, builderSetting, ENV_ENABLE_OTEL_DEBUG_METRICS);
}

private static boolean resolveFlag(
Function<String, String> env, @Nullable Boolean builderSetting, String envVarName) {
if (builderSetting != null) {
return builderSetting;
}
String javaEnv = env.apply(envVarName);
Boolean parsed = parseBooleanValue(javaEnv, envVarName);
if (parsed != null) {
return parsed;
}
return false;
}

@Nullable
@VisibleForTesting
static Boolean parseBooleanValue(@Nullable String val, String varName) {
if (val == null) {
return null;
}
String normalized = val.trim().toLowerCase(Locale.ENGLISH);
switch (normalized) {
case "1":
case "t":
case "true":
return Boolean.TRUE;
case "0":
case "f":
case "false":
return Boolean.FALSE;
default:
LOGGER.warning(
"Unrecognized boolean value '"
+ val
+ "' for "
+ varName
+ "; ignoring and falling back to builder/default");
return null;
}
}

@VisibleForTesting
static void setEnvResolverForTesting(Function<String, String> testEnv) {
envResolver = testEnv != null ? testEnv : System::getenv;
}

@VisibleForTesting
static void resetResolversForTesting() {
envResolver = System::getenv;
}
}
Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.