Skip to content
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.

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

feat: OpenTelemetry Trace Support #2837

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
f6dd4ab
feat: Instrument HTTP with OpenTelemetry (#2780)
sydney-munro Oct 17, 2024
5e6eb84
feat: Add OpenTelemetry Traces to GRPC (#2783)
sydney-munro Oct 22, 2024
c0abdf9
feat: create(Blob) instrumentation (#2792)
sydney-munro Oct 29, 2024
d9fd4bd
feat: Add CreateBlob for HTTP (#2803)
sydney-munro Oct 29, 2024
4538213
feat: Instrument HTTP Reads and Rewrites (#2808)
sydney-munro Nov 7, 2024
dc5a734
feat: Take in a module name when creating a span (#2811)
sydney-munro Nov 8, 2024
d7243f4
feat: Instrument HTTP readAllBytes (#2812)
sydney-munro Nov 11, 2024
2a85338
feat: Instrument ReadAllBytes and CreateFrom in gRPC (#2815)
sydney-munro Nov 14, 2024
57aeade
feat: Instrument gRPC downloadTo and Copy (#2818)
sydney-munro Nov 18, 2024
bd2fd5e
feat: Instrument HTTP createFrom (#2824)
sydney-munro Nov 25, 2024
6a2b3ca
chore: misc otel internalization/cleanup (#2835)
BenWhitehead Dec 5, 2024
125fc4e
feat: Instrument Reader and Writer methods (#2829)
sydney-munro Dec 6, 2024
56af555
chore: remove unnecessary context propagation (#2853)
sydney-munro Dec 17, 2024
3f8cb0f
Merge branch 'main' into otel-v1-branch
sydney-munro Dec 17, 2024
156b643
lint
sydney-munro Dec 17, 2024
cf94763
fix test failures
sydney-munro Dec 17, 2024
55e5770
remove otel-v1-branch sync repo settings and fix integ test
sydney-munro Dec 17, 2024
7c19e78
fix: cleanup span names for reader and writer (#2855)
BenWhitehead Dec 18, 2024
92989f5
pr comments
sydney-munro Dec 18, 2024
588b1c6
pr comments
sydney-munro Dec 18, 2024
499a95c
pr comments/fix typo
sydney-munro Dec 18, 2024
0776746
remove duplicated logic
sydney-munro Dec 19, 2024
f623d67
add back testbench deleted lines
sydney-munro Dec 19, 2024
3236dea
testbench formatting
sydney-munro Dec 19, 2024
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
13 changes: 13 additions & 0 deletions google-cloud-storage/clirr-ignored-differences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,17 @@
<method>boolean equals(java.lang.Object)</method>
</difference>

<difference>
<differenceType>7013</differenceType>
<className>com/google/cloud/storage/StorageOptions$Builder</className>
<method>com.google.cloud.storage.StorageOptions$Builder setOpenTelemetrySdk(io.opentelemetry.sdk.OpenTelemetrySdk)</method>
</difference>

<difference>
<differenceType>7013</differenceType>
<className>com/google/cloud/storage/StorageOptions</className>
<method>io.opentelemetry.sdk.OpenTelemetrySdk getOpenTelemetrySdk()</method>
</difference>


</differences>
9 changes: 9 additions & 0 deletions google-cloud-storage/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@
<groupId>io.opencensus</groupId>
<artifactId>opencensus-api</artifactId>
</dependency>
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-context</artifactId>
</dependency>
<dependency>
<groupId>com.google.api.grpc</groupId>
<artifactId>proto-google-iam-v1</artifactId>
Expand Down Expand Up @@ -205,6 +209,11 @@
<artifactId>grpc-googleapis</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-sdk-trace</artifactId>
<scope>test</scope>
</dependency>

<!--
We're not using this directly, however there appears to be some resolution
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
import io.grpc.MethodDescriptor;
import io.grpc.Status;
import io.grpc.protobuf.ProtoUtils;
import io.opentelemetry.sdk.OpenTelemetrySdk;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -119,6 +120,7 @@ public final class GrpcStorageOptions extends StorageOptions
private final boolean grpcClientMetricsManuallyEnabled;
private final GrpcInterceptorProvider grpcInterceptorProvider;
private final BlobWriteSessionConfig blobWriteSessionConfig;
private final OpenTelemetrySdk openTelemetrySdk;

private GrpcStorageOptions(Builder builder, GrpcStorageDefaults serviceDefaults) {
super(builder, serviceDefaults);
Expand All @@ -135,6 +137,7 @@ private GrpcStorageOptions(Builder builder, GrpcStorageDefaults serviceDefaults)
this.grpcClientMetricsManuallyEnabled = builder.grpcMetricsManuallyEnabled;
this.grpcInterceptorProvider = builder.grpcInterceptorProvider;
this.blobWriteSessionConfig = builder.blobWriteSessionConfig;
this.openTelemetrySdk = builder.openTelemetrySdk;
}

@Override
Expand Down Expand Up @@ -349,6 +352,11 @@ private Tuple<StorageSettings, Opts<UserProject>> resolveSettingsAndOpts() throw
return Tuple.of(builder.build(), defaultOpts);
}

@Override
public OpenTelemetrySdk getOpenTelemetrySdk() {
return openTelemetrySdk;
}

/** @since 2.14.0 */
@Override
public GrpcStorageOptions.Builder toBuilder() {
Expand Down Expand Up @@ -426,6 +434,8 @@ public static final class Builder extends StorageOptions.Builder {

private boolean grpcMetricsManuallyEnabled = false;

private OpenTelemetrySdk openTelemetrySdk;

Builder() {}

Builder(StorageOptions options) {
Expand All @@ -437,6 +447,7 @@ public static final class Builder extends StorageOptions.Builder {
this.enableGrpcClientMetrics = gso.enableGrpcClientMetrics;
this.grpcInterceptorProvider = gso.grpcInterceptorProvider;
this.blobWriteSessionConfig = gso.blobWriteSessionConfig;
this.openTelemetrySdk = gso.openTelemetrySdk;
}

/**
Expand Down Expand Up @@ -619,6 +630,19 @@ public GrpcStorageOptions.Builder setBlobWriteSessionConfig(
return this;
}

/**
* Enable OpenTelemetry Tracing and provide an instance for the client to use.
*
* @param openTelemetrySdk User defined instance of OpenTelemetry SDK to be used by the library
* @since 2.46.1 This new api is in preview and is subject to breaking changes.
*/
@BetaApi
public GrpcStorageOptions.Builder setOpenTelemetrySdk(OpenTelemetrySdk openTelemetrySdk) {
sydney-munro marked this conversation as resolved.
Show resolved Hide resolved
requireNonNull(openTelemetrySdk, "openTelemetry must be non null");
this.openTelemetrySdk = openTelemetrySdk;
return this;
}

/** @since 2.14.0 */
@Override
public GrpcStorageOptions build() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import com.google.cloud.storage.spi.v1.StorageRpc;
import com.google.common.base.MoreObjects;
import com.google.common.collect.ImmutableSet;
import io.opentelemetry.sdk.OpenTelemetrySdk;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.Serializable;
Expand All @@ -59,6 +60,8 @@ public class HttpStorageOptions extends StorageOptions {
private transient RetryDependenciesAdapter retryDepsAdapter;
private final BlobWriteSessionConfig blobWriteSessionConfig;

private final OpenTelemetrySdk openTelemetrySdk;

private HttpStorageOptions(Builder builder, StorageDefaults serviceDefaults) {
super(builder, serviceDefaults);
this.retryAlgorithmManager =
Expand All @@ -67,6 +70,7 @@ private HttpStorageOptions(Builder builder, StorageDefaults serviceDefaults) {
builder.storageRetryStrategy, defaults().getStorageRetryStrategy()));
retryDepsAdapter = new RetryDependenciesAdapter();
blobWriteSessionConfig = builder.blobWriteSessionConfig;
openTelemetrySdk = builder.openTelemetrySdk;
}

@Override
Expand All @@ -84,6 +88,11 @@ StorageRpc getStorageRpcV1() {
return (StorageRpc) getRpc();
}

@Override
public OpenTelemetrySdk getOpenTelemetrySdk() {
return openTelemetrySdk;
}

@Override
public HttpStorageOptions.Builder toBuilder() {
return new HttpStorageOptions.Builder(this);
Expand Down Expand Up @@ -135,6 +144,7 @@ public static class Builder extends StorageOptions.Builder {
private StorageRetryStrategy storageRetryStrategy;
private BlobWriteSessionConfig blobWriteSessionConfig =
HttpStorageDefaults.INSTANCE.getDefaultStorageWriterConfig();
private OpenTelemetrySdk openTelemetrySdk;

Builder() {}

Expand All @@ -143,6 +153,7 @@ public static class Builder extends StorageOptions.Builder {
HttpStorageOptions hso = (HttpStorageOptions) options;
this.storageRetryStrategy = hso.retryAlgorithmManager.retryStrategy;
this.blobWriteSessionConfig = hso.blobWriteSessionConfig;
this.openTelemetrySdk = hso.getOpenTelemetrySdk();
}

@Override
Expand Down Expand Up @@ -268,6 +279,19 @@ public HttpStorageOptions build() {
}
return options;
}

/**
* Enable OpenTelemetry Tracing and provide an instance for the client to use.
*
* @param openTelemetrySdk
* @since 2.46.1 This new api is in preview and is subject to breaking changes.
*/
@BetaApi
public HttpStorageOptions.Builder setOpenTelemetrySdk(OpenTelemetrySdk openTelemetrySdk) {
sydney-munro marked this conversation as resolved.
Show resolved Hide resolved
requireNonNull(openTelemetrySdk, "openTelemetry must be non null");
this.openTelemetrySdk = openTelemetrySdk;
return this;
}
}

public static final class HttpStorageDefaults extends StorageDefaults {
Expand Down
Loading
Loading