diff --git a/instrumentation/apache-httpclient/apache-httpclient-4.3/library/src/main/java/io/opentelemetry/instrumentation/apachehttpclient/v4_3/ApacheHttpClientTelemetryBuilder.java b/instrumentation/apache-httpclient/apache-httpclient-4.3/library/src/main/java/io/opentelemetry/instrumentation/apachehttpclient/v4_3/ApacheHttpClientTelemetryBuilder.java index d79c6f2cab6f..c2d3b715361e 100644 --- a/instrumentation/apache-httpclient/apache-httpclient-4.3/library/src/main/java/io/opentelemetry/instrumentation/apachehttpclient/v4_3/ApacheHttpClientTelemetryBuilder.java +++ b/instrumentation/apache-httpclient/apache-httpclient-4.3/library/src/main/java/io/opentelemetry/instrumentation/apachehttpclient/v4_3/ApacheHttpClientTelemetryBuilder.java @@ -7,6 +7,7 @@ import com.google.errorprone.annotations.CanIgnoreReturnValue; import io.opentelemetry.api.OpenTelemetry; +import io.opentelemetry.instrumentation.apachehttpclient.v4_3.internal.Experimental; import io.opentelemetry.instrumentation.api.incubator.builder.internal.DefaultHttpClientInstrumenterBuilder; import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; @@ -23,6 +24,11 @@ public final class ApacheHttpClientTelemetryBuilder { private final DefaultHttpClientInstrumenterBuilder builder; private final OpenTelemetry openTelemetry; + static { + Experimental.setSetEmitExperimentalTelemetry( + (builder, emit) -> builder.builder.setEmitExperimentalHttpClientMetrics(emit)); + } + ApacheHttpClientTelemetryBuilder(OpenTelemetry openTelemetry) { builder = DefaultHttpClientInstrumenterBuilder.create( @@ -103,7 +109,11 @@ public ApacheHttpClientTelemetryBuilder setKnownMethods(Set knownMethods * * @param emitExperimentalHttpClientMetrics {@code true} if the experimental HTTP client metrics * are to be emitted. + * @deprecated Use {@link + * Experimental#setEmitExperimentalTelemetry(ApacheHttpClientTelemetryBuilder, boolean)} + * instead. */ + @Deprecated @CanIgnoreReturnValue public ApacheHttpClientTelemetryBuilder setEmitExperimentalHttpClientMetrics( boolean emitExperimentalHttpClientMetrics) { diff --git a/instrumentation/apache-httpclient/apache-httpclient-4.3/library/src/main/java/io/opentelemetry/instrumentation/apachehttpclient/v4_3/internal/Experimental.java b/instrumentation/apache-httpclient/apache-httpclient-4.3/library/src/main/java/io/opentelemetry/instrumentation/apachehttpclient/v4_3/internal/Experimental.java new file mode 100644 index 000000000000..7a0016593f44 --- /dev/null +++ b/instrumentation/apache-httpclient/apache-httpclient-4.3/library/src/main/java/io/opentelemetry/instrumentation/apachehttpclient/v4_3/internal/Experimental.java @@ -0,0 +1,36 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.instrumentation.apachehttpclient.v4_3.internal; + +import io.opentelemetry.instrumentation.apachehttpclient.v4_3.ApacheHttpClientTelemetryBuilder; +import java.util.function.BiConsumer; +import javax.annotation.Nullable; + +/** + * This class is internal and experimental. Its APIs are unstable and can change at any time. Its + * APIs (or a version of them) may be promoted to the public stable API in the future, but no + * guarantees are made. + */ +public final class Experimental { + + @Nullable + private static volatile BiConsumer + setEmitExperimentalTelemetry; + + public static void setEmitExperimentalTelemetry( + ApacheHttpClientTelemetryBuilder builder, boolean emitExperimentalTelemetry) { + if (setEmitExperimentalTelemetry != null) { + setEmitExperimentalTelemetry.accept(builder, emitExperimentalTelemetry); + } + } + + public static void setSetEmitExperimentalTelemetry( + BiConsumer setEmitExperimentalTelemetry) { + Experimental.setEmitExperimentalTelemetry = setEmitExperimentalTelemetry; + } + + private Experimental() {} +} diff --git a/instrumentation/java-http-client/library/src/main/java/io/opentelemetry/instrumentation/httpclient/JavaHttpClientTelemetryBuilder.java b/instrumentation/java-http-client/library/src/main/java/io/opentelemetry/instrumentation/httpclient/JavaHttpClientTelemetryBuilder.java index 99c823609619..3c9c15143e3b 100644 --- a/instrumentation/java-http-client/library/src/main/java/io/opentelemetry/instrumentation/httpclient/JavaHttpClientTelemetryBuilder.java +++ b/instrumentation/java-http-client/library/src/main/java/io/opentelemetry/instrumentation/httpclient/JavaHttpClientTelemetryBuilder.java @@ -11,6 +11,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; import io.opentelemetry.instrumentation.api.semconv.http.HttpClientAttributesExtractorBuilder; +import io.opentelemetry.instrumentation.httpclient.internal.Experimental; import io.opentelemetry.instrumentation.httpclient.internal.HttpHeadersSetter; import io.opentelemetry.instrumentation.httpclient.internal.JavaHttpClientInstrumenterBuilderFactory; import java.net.http.HttpRequest; @@ -24,6 +25,11 @@ public final class JavaHttpClientTelemetryBuilder { private final DefaultHttpClientInstrumenterBuilder> builder; private final OpenTelemetry openTelemetry; + static { + Experimental.setSetEmitExperimentalTelemetry( + (builder, emit) -> builder.builder.setEmitExperimentalHttpClientMetrics(emit)); + } + JavaHttpClientTelemetryBuilder(OpenTelemetry openTelemetry) { builder = JavaHttpClientInstrumenterBuilderFactory.create(openTelemetry); this.openTelemetry = openTelemetry; @@ -100,7 +106,11 @@ public JavaHttpClientTelemetryBuilder setKnownMethods(Set knownMethods) * * @param emitExperimentalHttpClientMetrics {@code true} if the experimental HTTP client metrics * are to be emitted. + * @deprecated Use {@link + * Experimental#setEmitExperimentalTelemetry(JavaHttpClientTelemetryBuilder, boolean)} + * instead. */ + @Deprecated @CanIgnoreReturnValue public JavaHttpClientTelemetryBuilder setEmitExperimentalHttpClientMetrics( boolean emitExperimentalHttpClientMetrics) { diff --git a/instrumentation/java-http-client/library/src/main/java/io/opentelemetry/instrumentation/httpclient/internal/Experimental.java b/instrumentation/java-http-client/library/src/main/java/io/opentelemetry/instrumentation/httpclient/internal/Experimental.java new file mode 100644 index 000000000000..182b8d4c80e7 --- /dev/null +++ b/instrumentation/java-http-client/library/src/main/java/io/opentelemetry/instrumentation/httpclient/internal/Experimental.java @@ -0,0 +1,36 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.instrumentation.httpclient.internal; + +import io.opentelemetry.instrumentation.httpclient.JavaHttpClientTelemetryBuilder; +import java.util.function.BiConsumer; +import javax.annotation.Nullable; + +/** + * This class is internal and experimental. Its APIs are unstable and can change at any time. Its + * APIs (or a version of them) may be promoted to the public stable API in the future, but no + * guarantees are made. + */ +public final class Experimental { + + @Nullable + private static volatile BiConsumer + setEmitExperimentalTelemetry; + + public static void setEmitExperimentalTelemetry( + JavaHttpClientTelemetryBuilder builder, boolean emitExperimentalTelemetry) { + if (setEmitExperimentalTelemetry != null) { + setEmitExperimentalTelemetry.accept(builder, emitExperimentalTelemetry); + } + } + + public static void setSetEmitExperimentalTelemetry( + BiConsumer setEmitExperimentalTelemetry) { + Experimental.setEmitExperimentalTelemetry = setEmitExperimentalTelemetry; + } + + private Experimental() {} +} diff --git a/instrumentation/jetty-httpclient/jetty-httpclient-12.0/library/src/main/java/io/opentelemetry/instrumentation/jetty/httpclient/v12_0/JettyClientTelemetryBuilder.java b/instrumentation/jetty-httpclient/jetty-httpclient-12.0/library/src/main/java/io/opentelemetry/instrumentation/jetty/httpclient/v12_0/JettyClientTelemetryBuilder.java index aa137d18baf1..cf6063511ef9 100644 --- a/instrumentation/jetty-httpclient/jetty-httpclient-12.0/library/src/main/java/io/opentelemetry/instrumentation/jetty/httpclient/v12_0/JettyClientTelemetryBuilder.java +++ b/instrumentation/jetty-httpclient/jetty-httpclient-12.0/library/src/main/java/io/opentelemetry/instrumentation/jetty/httpclient/v12_0/JettyClientTelemetryBuilder.java @@ -11,6 +11,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; import io.opentelemetry.instrumentation.api.semconv.http.HttpClientAttributesExtractorBuilder; +import io.opentelemetry.instrumentation.jetty.httpclient.v12_0.internal.Experimental; import io.opentelemetry.instrumentation.jetty.httpclient.v12_0.internal.JettyHttpClientInstrumenterBuilderFactory; import java.util.List; import java.util.Set; @@ -26,6 +27,11 @@ public final class JettyClientTelemetryBuilder { private HttpClientTransport httpClientTransport; private SslContextFactory.Client sslContextFactory; + static { + Experimental.setSetEmitExperimentalTelemetry( + (builder, emit) -> builder.builder.setEmitExperimentalHttpClientMetrics(emit)); + } + JettyClientTelemetryBuilder(OpenTelemetry openTelemetry) { builder = JettyHttpClientInstrumenterBuilderFactory.create(openTelemetry); } @@ -115,7 +121,10 @@ public JettyClientTelemetryBuilder setKnownMethods(Set knownMethods) { * * @param emitExperimentalHttpClientMetrics {@code true} if the experimental HTTP client metrics * are to be emitted. + * @deprecated Use {@link Experimental#setEmitExperimentalTelemetry(JettyClientTelemetryBuilder, + * boolean)} instead. */ + @Deprecated @CanIgnoreReturnValue public JettyClientTelemetryBuilder setEmitExperimentalHttpClientMetrics( boolean emitExperimentalHttpClientMetrics) { diff --git a/instrumentation/jetty-httpclient/jetty-httpclient-12.0/library/src/main/java/io/opentelemetry/instrumentation/jetty/httpclient/v12_0/internal/Experimental.java b/instrumentation/jetty-httpclient/jetty-httpclient-12.0/library/src/main/java/io/opentelemetry/instrumentation/jetty/httpclient/v12_0/internal/Experimental.java new file mode 100644 index 000000000000..fc5424f929bd --- /dev/null +++ b/instrumentation/jetty-httpclient/jetty-httpclient-12.0/library/src/main/java/io/opentelemetry/instrumentation/jetty/httpclient/v12_0/internal/Experimental.java @@ -0,0 +1,36 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.instrumentation.jetty.httpclient.v12_0.internal; + +import io.opentelemetry.instrumentation.jetty.httpclient.v12_0.JettyClientTelemetryBuilder; +import java.util.function.BiConsumer; +import javax.annotation.Nullable; + +/** + * This class is internal and experimental. Its APIs are unstable and can change at any time. Its + * APIs (or a version of them) may be promoted to the public stable API in the future, but no + * guarantees are made. + */ +public final class Experimental { + + @Nullable + private static volatile BiConsumer + setEmitExperimentalTelemetry; + + public static void setEmitExperimentalTelemetry( + JettyClientTelemetryBuilder builder, boolean emitExperimentalTelemetry) { + if (setEmitExperimentalTelemetry != null) { + setEmitExperimentalTelemetry.accept(builder, emitExperimentalTelemetry); + } + } + + public static void setSetEmitExperimentalTelemetry( + BiConsumer setEmitExperimentalTelemetry) { + Experimental.setEmitExperimentalTelemetry = setEmitExperimentalTelemetry; + } + + private Experimental() {} +} diff --git a/instrumentation/jetty-httpclient/jetty-httpclient-9.2/library/src/main/java/io/opentelemetry/instrumentation/jetty/httpclient/v9_2/JettyClientTelemetryBuilder.java b/instrumentation/jetty-httpclient/jetty-httpclient-9.2/library/src/main/java/io/opentelemetry/instrumentation/jetty/httpclient/v9_2/JettyClientTelemetryBuilder.java index c414967a315a..4e4a9940e283 100644 --- a/instrumentation/jetty-httpclient/jetty-httpclient-9.2/library/src/main/java/io/opentelemetry/instrumentation/jetty/httpclient/v9_2/JettyClientTelemetryBuilder.java +++ b/instrumentation/jetty-httpclient/jetty-httpclient-9.2/library/src/main/java/io/opentelemetry/instrumentation/jetty/httpclient/v9_2/JettyClientTelemetryBuilder.java @@ -11,6 +11,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; import io.opentelemetry.instrumentation.api.semconv.http.HttpClientAttributesExtractorBuilder; +import io.opentelemetry.instrumentation.jetty.httpclient.v9_2.internal.Experimental; import io.opentelemetry.instrumentation.jetty.httpclient.v9_2.internal.JettyHttpClientInstrumenterBuilderFactory; import java.util.List; import java.util.Set; @@ -27,6 +28,11 @@ public final class JettyClientTelemetryBuilder { private HttpClientTransport httpClientTransport; private SslContextFactory sslContextFactory; + static { + Experimental.setSetEmitExperimentalTelemetry( + (builder, emit) -> builder.builder.setEmitExperimentalHttpClientMetrics(emit)); + } + JettyClientTelemetryBuilder(OpenTelemetry openTelemetry) { builder = JettyHttpClientInstrumenterBuilderFactory.create(openTelemetry); } @@ -115,7 +121,10 @@ public JettyClientTelemetryBuilder setKnownMethods(Set knownMethods) { * * @param emitExperimentalHttpClientMetrics {@code true} if the experimental HTTP client metrics * are to be emitted. + * @deprecated Use {@link Experimental#setEmitExperimentalTelemetry(JettyClientTelemetryBuilder, + * boolean)} instead. */ + @Deprecated @CanIgnoreReturnValue public JettyClientTelemetryBuilder setEmitExperimentalHttpClientMetrics( boolean emitExperimentalHttpClientMetrics) { diff --git a/instrumentation/jetty-httpclient/jetty-httpclient-9.2/library/src/main/java/io/opentelemetry/instrumentation/jetty/httpclient/v9_2/internal/Experimental.java b/instrumentation/jetty-httpclient/jetty-httpclient-9.2/library/src/main/java/io/opentelemetry/instrumentation/jetty/httpclient/v9_2/internal/Experimental.java new file mode 100644 index 000000000000..86b0a5d97081 --- /dev/null +++ b/instrumentation/jetty-httpclient/jetty-httpclient-9.2/library/src/main/java/io/opentelemetry/instrumentation/jetty/httpclient/v9_2/internal/Experimental.java @@ -0,0 +1,36 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.instrumentation.jetty.httpclient.v9_2.internal; + +import io.opentelemetry.instrumentation.jetty.httpclient.v9_2.JettyClientTelemetryBuilder; +import java.util.function.BiConsumer; +import javax.annotation.Nullable; + +/** + * This class is internal and experimental. Its APIs are unstable and can change at any time. Its + * APIs (or a version of them) may be promoted to the public stable API in the future, but no + * guarantees are made. + */ +public final class Experimental { + + @Nullable + private static volatile BiConsumer + setEmitExperimentalTelemetry; + + public static void setEmitExperimentalTelemetry( + JettyClientTelemetryBuilder builder, boolean emitExperimentalTelemetry) { + if (setEmitExperimentalTelemetry != null) { + setEmitExperimentalTelemetry.accept(builder, emitExperimentalTelemetry); + } + } + + public static void setSetEmitExperimentalTelemetry( + BiConsumer setEmitExperimentalTelemetry) { + Experimental.setEmitExperimentalTelemetry = setEmitExperimentalTelemetry; + } + + private Experimental() {} +} diff --git a/instrumentation/netty/netty-4.1/library/src/main/java/io/opentelemetry/instrumentation/netty/v4_1/NettyClientTelemetryBuilder.java b/instrumentation/netty/netty-4.1/library/src/main/java/io/opentelemetry/instrumentation/netty/v4_1/NettyClientTelemetryBuilder.java index d43c09ee4431..29a6cfe54a66 100644 --- a/instrumentation/netty/netty-4.1/library/src/main/java/io/opentelemetry/instrumentation/netty/v4_1/NettyClientTelemetryBuilder.java +++ b/instrumentation/netty/netty-4.1/library/src/main/java/io/opentelemetry/instrumentation/netty/v4_1/NettyClientTelemetryBuilder.java @@ -16,6 +16,7 @@ import io.opentelemetry.instrumentation.netty.v4.common.internal.client.NettyClientInstrumenterBuilderFactory; import io.opentelemetry.instrumentation.netty.v4.common.internal.client.NettyClientInstrumenterFactory; import io.opentelemetry.instrumentation.netty.v4.common.internal.client.NettyConnectionInstrumentationFlag; +import io.opentelemetry.instrumentation.netty.v4_1.internal.Experimental; import java.util.List; import java.util.Set; import java.util.function.Function; @@ -26,11 +27,24 @@ public final class NettyClientTelemetryBuilder { private final DefaultHttpClientInstrumenterBuilder builder; private boolean emitExperimentalHttpClientEvents = false; + static { + Experimental.setSetEmitExperimentalClientTelemetry( + (builder, emit) -> { + builder.builder.setEmitExperimentalHttpClientMetrics(emit); + builder.emitExperimentalHttpClientEvents = emit; + }); + } + NettyClientTelemetryBuilder(OpenTelemetry openTelemetry) { builder = NettyClientInstrumenterBuilderFactory.create("io.opentelemetry.netty-4.1", openTelemetry); } + /** + * @deprecated Use {@link Experimental#setEmitExperimentalTelemetry(NettyClientTelemetryBuilder, + * boolean)} instead. + */ + @Deprecated @CanIgnoreReturnValue public NettyClientTelemetryBuilder setEmitExperimentalHttpClientEvents( boolean emitExperimentalHttpClientEvents) { @@ -97,7 +111,10 @@ public NettyClientTelemetryBuilder setKnownMethods(Set knownMethods) { * * @param emitExperimentalHttpClientMetrics {@code true} if the experimental HTTP client metrics * are to be emitted. + * @deprecated Use {@link Experimental#setEmitExperimentalTelemetry(NettyClientTelemetryBuilder, + * boolean)} instead. */ + @Deprecated @CanIgnoreReturnValue public NettyClientTelemetryBuilder setEmitExperimentalHttpClientMetrics( boolean emitExperimentalHttpClientMetrics) { diff --git a/instrumentation/netty/netty-4.1/library/src/main/java/io/opentelemetry/instrumentation/netty/v4_1/NettyServerTelemetryBuilder.java b/instrumentation/netty/netty-4.1/library/src/main/java/io/opentelemetry/instrumentation/netty/v4_1/NettyServerTelemetryBuilder.java index 874bcb586bed..f7ba3b78751d 100644 --- a/instrumentation/netty/netty-4.1/library/src/main/java/io/opentelemetry/instrumentation/netty/v4_1/NettyServerTelemetryBuilder.java +++ b/instrumentation/netty/netty-4.1/library/src/main/java/io/opentelemetry/instrumentation/netty/v4_1/NettyServerTelemetryBuilder.java @@ -13,6 +13,7 @@ import io.opentelemetry.instrumentation.netty.v4.common.HttpRequestAndChannel; import io.opentelemetry.instrumentation.netty.v4.common.internal.server.HttpRequestHeadersGetter; import io.opentelemetry.instrumentation.netty.v4.common.internal.server.NettyHttpServerAttributesGetter; +import io.opentelemetry.instrumentation.netty.v4_1.internal.Experimental; import io.opentelemetry.instrumentation.netty.v4_1.internal.ProtocolEventHandler; import io.opentelemetry.instrumentation.netty.v4_1.internal.server.NettyServerInstrumenterBuilderUtil; import java.util.List; @@ -28,6 +29,11 @@ public final class NettyServerTelemetryBuilder { static { NettyServerInstrumenterBuilderUtil.setBuilderExtractor( nettyServerTelemetryBuilder -> nettyServerTelemetryBuilder.builder); + Experimental.setSetEmitExperimentalServerTelemetry( + (builder, emit) -> { + builder.builder.setEmitExperimentalHttpServerMetrics(emit); + builder.emitExperimentalHttpServerEvents = emit; + }); } NettyServerTelemetryBuilder(OpenTelemetry openTelemetry) { @@ -99,7 +105,10 @@ public NettyServerTelemetryBuilder setKnownMethods(Set knownMethods) { * * @param emitExperimentalHttpServerMetrics {@code true} if the experimental HTTP server metrics * are to be emitted. + * @deprecated Use {@link Experimental#setEmitExperimentalTelemetry(NettyServerTelemetryBuilder, + * boolean)} instead. */ + @Deprecated @CanIgnoreReturnValue public NettyServerTelemetryBuilder setEmitExperimentalHttpServerMetrics( boolean emitExperimentalHttpServerMetrics) { diff --git a/instrumentation/netty/netty-4.1/library/src/main/java/io/opentelemetry/instrumentation/netty/v4_1/internal/Experimental.java b/instrumentation/netty/netty-4.1/library/src/main/java/io/opentelemetry/instrumentation/netty/v4_1/internal/Experimental.java new file mode 100644 index 000000000000..d6b2c6c39207 --- /dev/null +++ b/instrumentation/netty/netty-4.1/library/src/main/java/io/opentelemetry/instrumentation/netty/v4_1/internal/Experimental.java @@ -0,0 +1,53 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.instrumentation.netty.v4_1.internal; + +import io.opentelemetry.instrumentation.netty.v4_1.NettyClientTelemetryBuilder; +import io.opentelemetry.instrumentation.netty.v4_1.NettyServerTelemetryBuilder; +import java.util.function.BiConsumer; +import javax.annotation.Nullable; + +/** + * This class is internal and experimental. Its APIs are unstable and can change at any time. Its + * APIs (or a version of them) may be promoted to the public stable API in the future, but no + * guarantees are made. + */ +public final class Experimental { + + @Nullable + private static volatile BiConsumer + setEmitExperimentalClientTelemetry; + + @Nullable + private static volatile BiConsumer + setEmitExperimentalServerTelemetry; + + public static void setEmitExperimentalTelemetry( + NettyClientTelemetryBuilder builder, boolean emitExperimentalTelemetry) { + if (setEmitExperimentalClientTelemetry != null) { + setEmitExperimentalClientTelemetry.accept(builder, emitExperimentalTelemetry); + } + } + + public static void setEmitExperimentalTelemetry( + NettyServerTelemetryBuilder builder, boolean emitExperimentalTelemetry) { + if (setEmitExperimentalServerTelemetry != null) { + setEmitExperimentalServerTelemetry.accept(builder, emitExperimentalTelemetry); + } + } + + public static void setSetEmitExperimentalClientTelemetry( + BiConsumer setEmitExperimentalClientTelemetry) { + Experimental.setEmitExperimentalClientTelemetry = setEmitExperimentalClientTelemetry; + } + + public static void setSetEmitExperimentalServerTelemetry( + BiConsumer setEmitExperimentalServerTelemetry) { + Experimental.setEmitExperimentalServerTelemetry = setEmitExperimentalServerTelemetry; + } + + private Experimental() {} +} diff --git a/instrumentation/okhttp/okhttp-3.0/library/src/main/java/io/opentelemetry/instrumentation/okhttp/v3_0/OkHttpTelemetryBuilder.java b/instrumentation/okhttp/okhttp-3.0/library/src/main/java/io/opentelemetry/instrumentation/okhttp/v3_0/OkHttpTelemetryBuilder.java index a6f642c346d0..13aa7e220393 100644 --- a/instrumentation/okhttp/okhttp-3.0/library/src/main/java/io/opentelemetry/instrumentation/okhttp/v3_0/OkHttpTelemetryBuilder.java +++ b/instrumentation/okhttp/okhttp-3.0/library/src/main/java/io/opentelemetry/instrumentation/okhttp/v3_0/OkHttpTelemetryBuilder.java @@ -11,6 +11,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; import io.opentelemetry.instrumentation.api.semconv.http.HttpClientAttributesExtractorBuilder; +import io.opentelemetry.instrumentation.okhttp.v3_0.internal.Experimental; import io.opentelemetry.instrumentation.okhttp.v3_0.internal.OkHttpClientInstrumenterBuilderFactory; import java.util.List; import java.util.Set; @@ -24,6 +25,11 @@ public final class OkHttpTelemetryBuilder { private final DefaultHttpClientInstrumenterBuilder builder; private final OpenTelemetry openTelemetry; + static { + Experimental.setSetEmitExperimentalTelemetry( + (builder, emit) -> builder.builder.setEmitExperimentalHttpClientMetrics(emit)); + } + OkHttpTelemetryBuilder(OpenTelemetry openTelemetry) { builder = OkHttpClientInstrumenterBuilderFactory.create(openTelemetry); this.openTelemetry = openTelemetry; @@ -100,7 +106,10 @@ public OkHttpTelemetryBuilder setKnownMethods(Set knownMethods) { * * @param emitExperimentalHttpClientMetrics {@code true} if the experimental HTTP client metrics * are to be emitted. + * @deprecated Use {@link Experimental#setEmitExperimentalTelemetry(OkHttpTelemetryBuilder, + * boolean)} instead. */ + @Deprecated @CanIgnoreReturnValue public OkHttpTelemetryBuilder setEmitExperimentalHttpClientMetrics( boolean emitExperimentalHttpClientMetrics) { diff --git a/instrumentation/okhttp/okhttp-3.0/library/src/main/java/io/opentelemetry/instrumentation/okhttp/v3_0/internal/Experimental.java b/instrumentation/okhttp/okhttp-3.0/library/src/main/java/io/opentelemetry/instrumentation/okhttp/v3_0/internal/Experimental.java new file mode 100644 index 000000000000..6762b56ec112 --- /dev/null +++ b/instrumentation/okhttp/okhttp-3.0/library/src/main/java/io/opentelemetry/instrumentation/okhttp/v3_0/internal/Experimental.java @@ -0,0 +1,35 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.instrumentation.okhttp.v3_0.internal; + +import io.opentelemetry.instrumentation.okhttp.v3_0.OkHttpTelemetryBuilder; +import java.util.function.BiConsumer; +import javax.annotation.Nullable; + +/** + * This class is internal and experimental. Its APIs are unstable and can change at any time. Its + * APIs (or a version of them) may be promoted to the public stable API in the future, but no + * guarantees are made. + */ +public final class Experimental { + + @Nullable + private static volatile BiConsumer setEmitExperimentalTelemetry; + + public static void setEmitExperimentalTelemetry( + OkHttpTelemetryBuilder builder, boolean emitExperimentalTelemetry) { + if (setEmitExperimentalTelemetry != null) { + setEmitExperimentalTelemetry.accept(builder, emitExperimentalTelemetry); + } + } + + public static void setSetEmitExperimentalTelemetry( + BiConsumer setEmitExperimentalTelemetry) { + Experimental.setEmitExperimentalTelemetry = setEmitExperimentalTelemetry; + } + + private Experimental() {} +} diff --git a/instrumentation/restlet/restlet-1.1/library/src/main/java/io/opentelemetry/instrumentation/restlet/v1_1/RestletTelemetryBuilder.java b/instrumentation/restlet/restlet-1.1/library/src/main/java/io/opentelemetry/instrumentation/restlet/v1_1/RestletTelemetryBuilder.java index 3ff61af4a73f..453ab82d3c47 100644 --- a/instrumentation/restlet/restlet-1.1/library/src/main/java/io/opentelemetry/instrumentation/restlet/v1_1/RestletTelemetryBuilder.java +++ b/instrumentation/restlet/restlet-1.1/library/src/main/java/io/opentelemetry/instrumentation/restlet/v1_1/RestletTelemetryBuilder.java @@ -11,6 +11,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; import io.opentelemetry.instrumentation.api.semconv.http.HttpServerAttributesExtractorBuilder; +import io.opentelemetry.instrumentation.restlet.v1_1.internal.Experimental; import io.opentelemetry.instrumentation.restlet.v1_1.internal.RestletTelemetryBuilderFactory; import java.util.List; import java.util.Set; @@ -23,6 +24,11 @@ public final class RestletTelemetryBuilder { private final DefaultHttpServerInstrumenterBuilder builder; + static { + Experimental.setSetEmitExperimentalTelemetry( + (builder, emit) -> builder.builder.setEmitExperimentalHttpServerMetrics(emit)); + } + RestletTelemetryBuilder(OpenTelemetry openTelemetry) { builder = RestletTelemetryBuilderFactory.create(openTelemetry); } @@ -84,7 +90,10 @@ public RestletTelemetryBuilder setKnownMethods(Set knownMethods) { * * @param emitExperimentalHttpServerMetrics {@code true} if the experimental HTTP server metrics * are to be emitted. + * @deprecated Use {@link Experimental#setEmitExperimentalTelemetry(RestletTelemetryBuilder, + * boolean)} instead. */ + @Deprecated @CanIgnoreReturnValue public RestletTelemetryBuilder setEmitExperimentalHttpServerMetrics( boolean emitExperimentalHttpServerMetrics) { diff --git a/instrumentation/restlet/restlet-1.1/library/src/main/java/io/opentelemetry/instrumentation/restlet/v1_1/internal/Experimental.java b/instrumentation/restlet/restlet-1.1/library/src/main/java/io/opentelemetry/instrumentation/restlet/v1_1/internal/Experimental.java new file mode 100644 index 000000000000..da576c6df9b5 --- /dev/null +++ b/instrumentation/restlet/restlet-1.1/library/src/main/java/io/opentelemetry/instrumentation/restlet/v1_1/internal/Experimental.java @@ -0,0 +1,35 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.instrumentation.restlet.v1_1.internal; + +import io.opentelemetry.instrumentation.restlet.v1_1.RestletTelemetryBuilder; +import java.util.function.BiConsumer; +import javax.annotation.Nullable; + +/** + * This class is internal and experimental. Its APIs are unstable and can change at any time. Its + * APIs (or a version of them) may be promoted to the public stable API in the future, but no + * guarantees are made. + */ +public final class Experimental { + + @Nullable + private static volatile BiConsumer setEmitExperimentalTelemetry; + + public static void setEmitExperimentalTelemetry( + RestletTelemetryBuilder builder, boolean emitExperimentalTelemetry) { + if (setEmitExperimentalTelemetry != null) { + setEmitExperimentalTelemetry.accept(builder, emitExperimentalTelemetry); + } + } + + public static void setSetEmitExperimentalTelemetry( + BiConsumer setEmitExperimentalTelemetry) { + Experimental.setEmitExperimentalTelemetry = setEmitExperimentalTelemetry; + } + + private Experimental() {} +} diff --git a/instrumentation/restlet/restlet-2.0/library/src/main/java/io/opentelemetry/instrumentation/restlet/v2_0/RestletTelemetryBuilder.java b/instrumentation/restlet/restlet-2.0/library/src/main/java/io/opentelemetry/instrumentation/restlet/v2_0/RestletTelemetryBuilder.java index a933f52cdea4..32a6421d5118 100644 --- a/instrumentation/restlet/restlet-2.0/library/src/main/java/io/opentelemetry/instrumentation/restlet/v2_0/RestletTelemetryBuilder.java +++ b/instrumentation/restlet/restlet-2.0/library/src/main/java/io/opentelemetry/instrumentation/restlet/v2_0/RestletTelemetryBuilder.java @@ -11,6 +11,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; import io.opentelemetry.instrumentation.api.semconv.http.HttpServerAttributesExtractorBuilder; +import io.opentelemetry.instrumentation.restlet.v2_0.internal.Experimental; import io.opentelemetry.instrumentation.restlet.v2_0.internal.RestletTelemetryBuilderFactory; import java.util.List; import java.util.Set; @@ -23,6 +24,11 @@ public final class RestletTelemetryBuilder { private final DefaultHttpServerInstrumenterBuilder builder; + static { + Experimental.setSetEmitExperimentalTelemetry( + (builder, emit) -> builder.builder.setEmitExperimentalHttpServerMetrics(emit)); + } + RestletTelemetryBuilder(OpenTelemetry openTelemetry) { builder = RestletTelemetryBuilderFactory.create(openTelemetry); } @@ -84,7 +90,10 @@ public RestletTelemetryBuilder setKnownMethods(Set knownMethods) { * * @param emitExperimentalHttpServerMetrics {@code true} if the experimental HTTP server metrics * are to be emitted. + * @deprecated Use {@link Experimental#setEmitExperimentalTelemetry(RestletTelemetryBuilder, + * boolean)} instead. */ + @Deprecated @CanIgnoreReturnValue public RestletTelemetryBuilder setEmitExperimentalHttpServerMetrics( boolean emitExperimentalHttpServerMetrics) { diff --git a/instrumentation/restlet/restlet-2.0/library/src/main/java/io/opentelemetry/instrumentation/restlet/v2_0/internal/Experimental.java b/instrumentation/restlet/restlet-2.0/library/src/main/java/io/opentelemetry/instrumentation/restlet/v2_0/internal/Experimental.java new file mode 100644 index 000000000000..36a1e95b7e78 --- /dev/null +++ b/instrumentation/restlet/restlet-2.0/library/src/main/java/io/opentelemetry/instrumentation/restlet/v2_0/internal/Experimental.java @@ -0,0 +1,35 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.instrumentation.restlet.v2_0.internal; + +import io.opentelemetry.instrumentation.restlet.v2_0.RestletTelemetryBuilder; +import java.util.function.BiConsumer; +import javax.annotation.Nullable; + +/** + * This class is internal and experimental. Its APIs are unstable and can change at any time. Its + * APIs (or a version of them) may be promoted to the public stable API in the future, but no + * guarantees are made. + */ +public final class Experimental { + + @Nullable + private static volatile BiConsumer setEmitExperimentalTelemetry; + + public static void setEmitExperimentalTelemetry( + RestletTelemetryBuilder builder, boolean emitExperimentalTelemetry) { + if (setEmitExperimentalTelemetry != null) { + setEmitExperimentalTelemetry.accept(builder, emitExperimentalTelemetry); + } + } + + public static void setSetEmitExperimentalTelemetry( + BiConsumer setEmitExperimentalTelemetry) { + Experimental.setEmitExperimentalTelemetry = setEmitExperimentalTelemetry; + } + + private Experimental() {} +} diff --git a/instrumentation/spring/spring-web/spring-web-3.1/library/src/main/java/io/opentelemetry/instrumentation/spring/web/v3_1/SpringWebTelemetryBuilder.java b/instrumentation/spring/spring-web/spring-web-3.1/library/src/main/java/io/opentelemetry/instrumentation/spring/web/v3_1/SpringWebTelemetryBuilder.java index 26c653fe7918..cc4d69fbad19 100644 --- a/instrumentation/spring/spring-web/spring-web-3.1/library/src/main/java/io/opentelemetry/instrumentation/spring/web/v3_1/SpringWebTelemetryBuilder.java +++ b/instrumentation/spring/spring-web/spring-web-3.1/library/src/main/java/io/opentelemetry/instrumentation/spring/web/v3_1/SpringWebTelemetryBuilder.java @@ -11,6 +11,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; import io.opentelemetry.instrumentation.api.semconv.http.HttpClientAttributesExtractorBuilder; +import io.opentelemetry.instrumentation.spring.web.v3_1.internal.Experimental; import io.opentelemetry.instrumentation.spring.web.v3_1.internal.WebTelemetryUtil; import java.util.List; import java.util.Set; @@ -25,6 +26,8 @@ public final class SpringWebTelemetryBuilder { static { WebTelemetryUtil.setBuilderExtractor(SpringWebTelemetryBuilder::getBuilder); + Experimental.setSetEmitExperimentalTelemetry( + (builder, emit) -> builder.builder.setEmitExperimentalHttpClientMetrics(emit)); } SpringWebTelemetryBuilder(OpenTelemetry openTelemetry) { @@ -122,7 +125,10 @@ public SpringWebTelemetryBuilder setKnownMethods(Set knownMethods) { * * @param emitExperimentalHttpClientMetrics {@code true} if the experimental HTTP client metrics * are to be emitted. + * @deprecated Use {@link Experimental#setEmitExperimentalTelemetry(SpringWebTelemetryBuilder, + * boolean)} instead. */ + @Deprecated @CanIgnoreReturnValue public SpringWebTelemetryBuilder setEmitExperimentalHttpClientMetrics( boolean emitExperimentalHttpClientMetrics) { diff --git a/instrumentation/spring/spring-web/spring-web-3.1/library/src/main/java/io/opentelemetry/instrumentation/spring/web/v3_1/internal/Experimental.java b/instrumentation/spring/spring-web/spring-web-3.1/library/src/main/java/io/opentelemetry/instrumentation/spring/web/v3_1/internal/Experimental.java new file mode 100644 index 000000000000..a336b1011e28 --- /dev/null +++ b/instrumentation/spring/spring-web/spring-web-3.1/library/src/main/java/io/opentelemetry/instrumentation/spring/web/v3_1/internal/Experimental.java @@ -0,0 +1,36 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.instrumentation.spring.web.v3_1.internal; + +import io.opentelemetry.instrumentation.spring.web.v3_1.SpringWebTelemetryBuilder; +import java.util.function.BiConsumer; +import javax.annotation.Nullable; + +/** + * This class is internal and experimental. Its APIs are unstable and can change at any time. Its + * APIs (or a version of them) may be promoted to the public stable API in the future, but no + * guarantees are made. + */ +public final class Experimental { + + @Nullable + private static volatile BiConsumer + setEmitExperimentalTelemetry; + + public static void setEmitExperimentalTelemetry( + SpringWebTelemetryBuilder builder, boolean emitExperimentalTelemetry) { + if (setEmitExperimentalTelemetry != null) { + setEmitExperimentalTelemetry.accept(builder, emitExperimentalTelemetry); + } + } + + public static void setSetEmitExperimentalTelemetry( + BiConsumer setEmitExperimentalTelemetry) { + Experimental.setEmitExperimentalTelemetry = setEmitExperimentalTelemetry; + } + + private Experimental() {} +} diff --git a/instrumentation/spring/spring-webmvc/spring-webmvc-5.3/library/src/main/java/io/opentelemetry/instrumentation/spring/webmvc/v5_3/SpringWebMvcTelemetryBuilder.java b/instrumentation/spring/spring-webmvc/spring-webmvc-5.3/library/src/main/java/io/opentelemetry/instrumentation/spring/webmvc/v5_3/SpringWebMvcTelemetryBuilder.java index a24abdad8105..b2f6c63785e4 100644 --- a/instrumentation/spring/spring-webmvc/spring-webmvc-5.3/library/src/main/java/io/opentelemetry/instrumentation/spring/webmvc/v5_3/SpringWebMvcTelemetryBuilder.java +++ b/instrumentation/spring/spring-webmvc/spring-webmvc-5.3/library/src/main/java/io/opentelemetry/instrumentation/spring/webmvc/v5_3/SpringWebMvcTelemetryBuilder.java @@ -11,6 +11,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; import io.opentelemetry.instrumentation.api.semconv.http.HttpServerAttributesExtractorBuilder; +import io.opentelemetry.instrumentation.spring.webmvc.v5_3.internal.Experimental; import io.opentelemetry.instrumentation.spring.webmvc.v5_3.internal.SpringMvcBuilderUtil; import java.util.List; import java.util.Set; @@ -28,6 +29,8 @@ public final class SpringWebMvcTelemetryBuilder { static { SpringMvcBuilderUtil.setBuilderExtractor(builder -> builder.builder); + Experimental.setSetEmitExperimentalTelemetry( + (builder, emit) -> builder.builder.setEmitExperimentalHttpServerMetrics(emit)); } SpringWebMvcTelemetryBuilder(OpenTelemetry openTelemetry) { @@ -107,7 +110,10 @@ public SpringWebMvcTelemetryBuilder setKnownMethods(Set knownMethods) { * * @param emitExperimentalHttpServerMetrics {@code true} if the experimental HTTP server metrics * are to be emitted. + * @deprecated Use {@link Experimental#setEmitExperimentalTelemetry(SpringWebMvcTelemetryBuilder, + * boolean)} instead. */ + @Deprecated @CanIgnoreReturnValue public SpringWebMvcTelemetryBuilder setEmitExperimentalHttpServerMetrics( boolean emitExperimentalHttpServerMetrics) { diff --git a/instrumentation/spring/spring-webmvc/spring-webmvc-5.3/library/src/main/java/io/opentelemetry/instrumentation/spring/webmvc/v5_3/internal/Experimental.java b/instrumentation/spring/spring-webmvc/spring-webmvc-5.3/library/src/main/java/io/opentelemetry/instrumentation/spring/webmvc/v5_3/internal/Experimental.java new file mode 100644 index 000000000000..89852cf60065 --- /dev/null +++ b/instrumentation/spring/spring-webmvc/spring-webmvc-5.3/library/src/main/java/io/opentelemetry/instrumentation/spring/webmvc/v5_3/internal/Experimental.java @@ -0,0 +1,36 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.instrumentation.spring.webmvc.v5_3.internal; + +import io.opentelemetry.instrumentation.spring.webmvc.v5_3.SpringWebMvcTelemetryBuilder; +import java.util.function.BiConsumer; +import javax.annotation.Nullable; + +/** + * This class is internal and experimental. Its APIs are unstable and can change at any time. Its + * APIs (or a version of them) may be promoted to the public stable API in the future, but no + * guarantees are made. + */ +public final class Experimental { + + @Nullable + private static volatile BiConsumer + setEmitExperimentalTelemetry; + + public static void setEmitExperimentalTelemetry( + SpringWebMvcTelemetryBuilder builder, boolean emitExperimentalTelemetry) { + if (setEmitExperimentalTelemetry != null) { + setEmitExperimentalTelemetry.accept(builder, emitExperimentalTelemetry); + } + } + + public static void setSetEmitExperimentalTelemetry( + BiConsumer setEmitExperimentalTelemetry) { + Experimental.setEmitExperimentalTelemetry = setEmitExperimentalTelemetry; + } + + private Experimental() {} +} diff --git a/instrumentation/spring/spring-webmvc/spring-webmvc-6.0/library/src/main/java/io/opentelemetry/instrumentation/spring/webmvc/v6_0/SpringWebMvcTelemetryBuilder.java b/instrumentation/spring/spring-webmvc/spring-webmvc-6.0/library/src/main/java/io/opentelemetry/instrumentation/spring/webmvc/v6_0/SpringWebMvcTelemetryBuilder.java index 7f768b057cbb..bc5df58458f3 100644 --- a/instrumentation/spring/spring-webmvc/spring-webmvc-6.0/library/src/main/java/io/opentelemetry/instrumentation/spring/webmvc/v6_0/SpringWebMvcTelemetryBuilder.java +++ b/instrumentation/spring/spring-webmvc/spring-webmvc-6.0/library/src/main/java/io/opentelemetry/instrumentation/spring/webmvc/v6_0/SpringWebMvcTelemetryBuilder.java @@ -11,6 +11,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; import io.opentelemetry.instrumentation.api.semconv.http.HttpServerAttributesExtractorBuilder; +import io.opentelemetry.instrumentation.spring.webmvc.v6_0.internal.Experimental; import io.opentelemetry.instrumentation.spring.webmvc.v6_0.internal.SpringMvcBuilderUtil; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; @@ -27,6 +28,8 @@ public final class SpringWebMvcTelemetryBuilder { static { SpringMvcBuilderUtil.setBuilderExtractor(builder -> builder.builder); + Experimental.setSetEmitExperimentalTelemetry( + (builder, emit) -> builder.builder.setEmitExperimentalHttpServerMetrics(emit)); } SpringWebMvcTelemetryBuilder(OpenTelemetry openTelemetry) { @@ -106,7 +109,10 @@ public SpringWebMvcTelemetryBuilder setKnownMethods(Set knownMethods) { * * @param emitExperimentalHttpServerMetrics {@code true} if the experimental HTTP server metrics * are to be emitted. + * @deprecated Use {@link Experimental#setEmitExperimentalTelemetry(SpringWebMvcTelemetryBuilder, + * boolean)} instead. */ + @Deprecated @CanIgnoreReturnValue public SpringWebMvcTelemetryBuilder setEmitExperimentalHttpServerMetrics( boolean emitExperimentalHttpServerMetrics) { diff --git a/instrumentation/spring/spring-webmvc/spring-webmvc-6.0/library/src/main/java/io/opentelemetry/instrumentation/spring/webmvc/v6_0/internal/Experimental.java b/instrumentation/spring/spring-webmvc/spring-webmvc-6.0/library/src/main/java/io/opentelemetry/instrumentation/spring/webmvc/v6_0/internal/Experimental.java new file mode 100644 index 000000000000..6c580539634c --- /dev/null +++ b/instrumentation/spring/spring-webmvc/spring-webmvc-6.0/library/src/main/java/io/opentelemetry/instrumentation/spring/webmvc/v6_0/internal/Experimental.java @@ -0,0 +1,36 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.instrumentation.spring.webmvc.v6_0.internal; + +import io.opentelemetry.instrumentation.spring.webmvc.v6_0.SpringWebMvcTelemetryBuilder; +import java.util.function.BiConsumer; +import javax.annotation.Nullable; + +/** + * This class is internal and experimental. Its APIs are unstable and can change at any time. Its + * APIs (or a version of them) may be promoted to the public stable API in the future, but no + * guarantees are made. + */ +public final class Experimental { + + @Nullable + private static volatile BiConsumer + setEmitExperimentalTelemetry; + + public static void setEmitExperimentalTelemetry( + SpringWebMvcTelemetryBuilder builder, boolean emitExperimentalTelemetry) { + if (setEmitExperimentalTelemetry != null) { + setEmitExperimentalTelemetry.accept(builder, emitExperimentalTelemetry); + } + } + + public static void setSetEmitExperimentalTelemetry( + BiConsumer setEmitExperimentalTelemetry) { + Experimental.setEmitExperimentalTelemetry = setEmitExperimentalTelemetry; + } + + private Experimental() {} +}