Skip to content
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 55 additions & 4 deletions google-cloud-storage/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,53 @@
<groupId>com.google.api.grpc</groupId>
<artifactId>gapic-google-cloud-storage-v2</artifactId>
</dependency>
<!-- Open Telemetry dependencies -->
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-sdk</artifactId>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-opentelemetry</artifactId>
</dependency>
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-api</artifactId>
</dependency>

<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-sdk-metrics</artifactId>
</dependency>
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-sdk-common</artifactId>
</dependency>

<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-sdk-extension-autoconfigure-spi</artifactId>
</dependency>

<dependency>
<groupId>io.opentelemetry.semconv</groupId>
<artifactId>opentelemetry-semconv</artifactId>
</dependency>

<dependency>
<groupId>com.google.cloud.opentelemetry</groupId>
<artifactId>exporter-metrics</artifactId>
</dependency>

<dependency>
<groupId>io.opentelemetry.contrib</groupId>
<artifactId>opentelemetry-gcp-resources</artifactId>
</dependency>

<dependency>
<groupId>org.checkerframework</groupId>
<artifactId>checker-qual</artifactId>
</dependency>

<!-- Access to exception for retry handling -->
<dependency>
Expand Down Expand Up @@ -159,10 +206,7 @@
<artifactId>grpc-googleapis</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.checkerframework</groupId>
<artifactId>checker-qual</artifactId>
</dependency>

<!--
We're not using this directly, however there appears to be some resolution
issues when we don't list this dependency. Specifically, the check to ensure the flattened
Expand All @@ -184,6 +228,7 @@
<version>0.140.0</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-kms</artifactId>
Expand Down Expand Up @@ -307,6 +352,12 @@
Add in vintage engine so that both JUnit4 and JUnit5 tests are run by the JUnit5 runner.
-->
<dependency>org.junit.vintage:junit-vintage-engine</dependency>

<!--
These are needed at compile time, but it causes unused declared dependency errors
-->
<dependency>io.opentelemetry:opentelemetry-sdk-extension-autoconfigure-spi</dependency>
<dependency>io.opentelemetry.semconv:opentelemetry-semconv</dependency>
</ignoredDependencies>
</configuration>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ public final class GrpcStorageOptions extends StorageOptions
private final GrpcRetryAlgorithmManager retryAlgorithmManager;
private final Duration terminationAwaitDuration;
private final boolean attemptDirectPath;
private final boolean enableMetrics;
private final GrpcInterceptorProvider grpcInterceptorProvider;
private final BlobWriteSessionConfig blobWriteSessionConfig;

Expand All @@ -129,6 +130,7 @@ private GrpcStorageOptions(Builder builder, GrpcStorageDefaults serviceDefaults)
MoreObjects.firstNonNull(
builder.terminationAwaitDuration, serviceDefaults.getTerminationAwaitDuration());
this.attemptDirectPath = builder.attemptDirectPath;
this.enableMetrics = builder.enableGrpcClientMetrics;
this.grpcInterceptorProvider = builder.grpcInterceptorProvider;
this.blobWriteSessionConfig = builder.blobWriteSessionConfig;
}
Expand Down Expand Up @@ -287,6 +289,12 @@ private Tuple<StorageSettings, Opts<UserProject>> resolveSettingsAndOpts() throw
if (scheme.equals("http")) {
channelProviderBuilder.setChannelConfigurator(ManagedChannelBuilder::usePlaintext);
}

if (enableMetrics) {
OpenTelemetryBootstrappingUtils.enableGrpcMetrics(
channelProviderBuilder, endpoint, this.getProjectId(), this.getUniverseDomain());
}

builder.setTransportChannelProvider(channelProviderBuilder.build());
RetrySettings baseRetrySettings = getRetrySettings();
RetrySettings readRetrySettings =
Expand Down Expand Up @@ -350,6 +358,7 @@ public int hashCode() {
retryAlgorithmManager,
terminationAwaitDuration,
attemptDirectPath,
enableMetrics,
grpcInterceptorProvider,
blobWriteSessionConfig,
baseHashCode());
Expand All @@ -365,6 +374,7 @@ public boolean equals(Object o) {
}
GrpcStorageOptions that = (GrpcStorageOptions) o;
return attemptDirectPath == that.attemptDirectPath
&& enableMetrics == that.enableMetrics
&& Objects.equals(retryAlgorithmManager, that.retryAlgorithmManager)
&& Objects.equals(terminationAwaitDuration, that.terminationAwaitDuration)
&& Objects.equals(grpcInterceptorProvider, that.grpcInterceptorProvider)
Expand Down Expand Up @@ -408,6 +418,7 @@ public static final class Builder extends StorageOptions.Builder {
private StorageRetryStrategy storageRetryStrategy;
private Duration terminationAwaitDuration;
private boolean attemptDirectPath = GrpcStorageDefaults.INSTANCE.isAttemptDirectPath();
private boolean enableGrpcClientMetrics = GrpcStorageDefaults.INSTANCE.isEnableMetrics();
private GrpcInterceptorProvider grpcInterceptorProvider =
GrpcStorageDefaults.INSTANCE.grpcInterceptorProvider();
private BlobWriteSessionConfig blobWriteSessionConfig =
Expand All @@ -421,6 +432,7 @@ public static final class Builder extends StorageOptions.Builder {
this.storageRetryStrategy = gso.getRetryAlgorithmManager().retryStrategy;
this.terminationAwaitDuration = gso.getTerminationAwaitDuration();
this.attemptDirectPath = gso.attemptDirectPath;
this.enableGrpcClientMetrics = gso.enableMetrics;
this.grpcInterceptorProvider = gso.grpcInterceptorProvider;
this.blobWriteSessionConfig = gso.blobWriteSessionConfig;
}
Expand Down Expand Up @@ -454,6 +466,18 @@ public GrpcStorageOptions.Builder setAttemptDirectPath(boolean attemptDirectPath
this.attemptDirectPath = attemptDirectPath;
return this;
}
/**
* Option for whether this client should emit internal gRPC client internal metrics to Cloud
* Monitoring. To disable metric reporting, set this to false. True by default. Emitting metrics
* is free and requires minimal CPU and memory.
*
* @since 2.41.0 This new api is in preview and is subject to breaking changes.
*/
@BetaApi
public GrpcStorageOptions.Builder setEnableGrpcClientMetrics(boolean enableGrpcClientMetrics) {
this.enableGrpcClientMetrics = enableGrpcClientMetrics;
return this;
}

/** @since 2.14.0 This new api is in preview and is subject to breaking changes. */
@BetaApi
Expand Down Expand Up @@ -660,6 +684,12 @@ public boolean isAttemptDirectPath() {
return false;
}

/** @since 2.41.0 This new api is in preview and is subject to breaking changes. */
@BetaApi
public boolean isEnableMetrics() {
return true;
}

/** @since 2.22.3 This new api is in preview and is subject to breaking changes. */
@BetaApi
public GrpcInterceptorProvider grpcInterceptorProvider() {
Expand Down
Loading