Skip to content

Commit ce4bd9b

Browse files
committed
Move experimental methods out of public API
1 parent 4af0dd5 commit ce4bd9b

File tree

23 files changed

+732
-0
lines changed

23 files changed

+732
-0
lines changed

instrumentation/apache-httpclient/apache-httpclient-4.3/library/src/main/java/io/opentelemetry/instrumentation/apachehttpclient/v4_3/ApacheHttpClientTelemetryBuilder.java

+5
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import com.google.errorprone.annotations.CanIgnoreReturnValue;
99
import io.opentelemetry.api.OpenTelemetry;
10+
import io.opentelemetry.instrumentation.apachehttpclient.v4_3.internal.Experimental;
1011
import io.opentelemetry.instrumentation.api.incubator.builder.internal.DefaultHttpClientInstrumenterBuilder;
1112
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
1213
import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor;
@@ -88,7 +89,11 @@ public ApacheHttpClientTelemetryBuilder setKnownMethods(Set<String> knownMethods
8889
*
8990
* @param emitExperimentalHttpClientMetrics {@code true} if the experimental HTTP client metrics
9091
* are to be emitted.
92+
* @deprecated Use {@link
93+
* Experimental#setEmitExperimentalHttpClientMetrics(ApacheHttpClientTelemetryBuilder,
94+
* boolean)} instead.
9195
*/
96+
@Deprecated
9297
@CanIgnoreReturnValue
9398
public ApacheHttpClientTelemetryBuilder setEmitExperimentalHttpClientMetrics(
9499
boolean emitExperimentalHttpClientMetrics) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package io.opentelemetry.instrumentation.apachehttpclient.v4_3.internal;
7+
8+
import static java.util.logging.Level.FINE;
9+
10+
import io.opentelemetry.instrumentation.apachehttpclient.v4_3.ApacheHttpClientTelemetryBuilder;
11+
import java.lang.reflect.InvocationTargetException;
12+
import java.lang.reflect.Method;
13+
import java.util.logging.Logger;
14+
import javax.annotation.Nullable;
15+
16+
/**
17+
* This class is internal and is hence not for public use. Its APIs are unstable and can change at
18+
* any time.
19+
*/
20+
// TODO (trask) update the above javadoc similar to
21+
// https://github.com/open-telemetry/opentelemetry-java/pull/6886
22+
public class Experimental {
23+
24+
private static final Logger logger = Logger.getLogger(Experimental.class.getName());
25+
26+
@Nullable
27+
private static final Method emitExperimentalHttpClientMetricsMethod =
28+
getEmitExperimentalHttpClientMetricsMethod();
29+
30+
public void setEmitExperimentalHttpClientMetrics(
31+
ApacheHttpClientTelemetryBuilder builder, boolean emitExperimentalHttpClientMetrics) {
32+
33+
if (emitExperimentalHttpClientMetricsMethod != null) {
34+
try {
35+
emitExperimentalHttpClientMetricsMethod.invoke(builder, emitExperimentalHttpClientMetrics);
36+
} catch (IllegalAccessException | InvocationTargetException e) {
37+
logger.log(FINE, e.getMessage(), e);
38+
}
39+
}
40+
}
41+
42+
@Nullable
43+
private static Method getEmitExperimentalHttpClientMetricsMethod() {
44+
try {
45+
Method method =
46+
ApacheHttpClientTelemetryBuilder.class.getDeclaredMethod(
47+
"setEmitExperimentalHttpClientMetrics", boolean.class);
48+
method.setAccessible(true);
49+
return method;
50+
} catch (NoSuchMethodException e) {
51+
logger.log(FINE, e.getMessage(), e);
52+
return null;
53+
}
54+
}
55+
}

instrumentation/java-http-client/library/src/main/java/io/opentelemetry/instrumentation/httpclient/JavaHttpClientTelemetryBuilder.java

+5
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
1212
import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor;
1313
import io.opentelemetry.instrumentation.api.semconv.http.HttpClientAttributesExtractorBuilder;
14+
import io.opentelemetry.instrumentation.httpclient.internal.Experimental;
1415
import io.opentelemetry.instrumentation.httpclient.internal.HttpHeadersSetter;
1516
import io.opentelemetry.instrumentation.httpclient.internal.JavaHttpClientInstrumenterBuilderFactory;
1617
import java.net.http.HttpRequest;
@@ -86,7 +87,11 @@ public JavaHttpClientTelemetryBuilder setKnownMethods(Set<String> knownMethods)
8687
*
8788
* @param emitExperimentalHttpClientMetrics {@code true} if the experimental HTTP client metrics
8889
* are to be emitted.
90+
* @deprecated Use {@link
91+
* Experimental#setEmitExperimentalHttpClientMetrics(JavaHttpClientTelemetryBuilder, boolean)}
92+
* instead.
8993
*/
94+
@Deprecated
9095
@CanIgnoreReturnValue
9196
public JavaHttpClientTelemetryBuilder setEmitExperimentalHttpClientMetrics(
9297
boolean emitExperimentalHttpClientMetrics) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package io.opentelemetry.instrumentation.httpclient.internal;
7+
8+
import static java.util.logging.Level.FINE;
9+
10+
import io.opentelemetry.instrumentation.httpclient.JavaHttpClientTelemetryBuilder;
11+
import java.lang.reflect.InvocationTargetException;
12+
import java.lang.reflect.Method;
13+
import java.util.logging.Logger;
14+
import javax.annotation.Nullable;
15+
16+
/**
17+
* This class is internal and is hence not for public use. Its APIs are unstable and can change at
18+
* any time.
19+
*/
20+
// TODO (trask) update the above javadoc similar to
21+
// https://github.com/open-telemetry/opentelemetry-java/pull/6886
22+
public class Experimental {
23+
24+
private static final Logger logger = Logger.getLogger(Experimental.class.getName());
25+
26+
@Nullable
27+
private static final Method emitExperimentalHttpClientMetricsMethod =
28+
getEmitExperimentalHttpClientMetricsMethod();
29+
30+
public void setEmitExperimentalHttpClientMetrics(
31+
JavaHttpClientTelemetryBuilder builder, boolean emitExperimentalHttpClientMetrics) {
32+
33+
if (emitExperimentalHttpClientMetricsMethod != null) {
34+
try {
35+
emitExperimentalHttpClientMetricsMethod.invoke(builder, emitExperimentalHttpClientMetrics);
36+
} catch (IllegalAccessException | InvocationTargetException e) {
37+
logger.log(FINE, e.getMessage(), e);
38+
}
39+
}
40+
}
41+
42+
@Nullable
43+
private static Method getEmitExperimentalHttpClientMetricsMethod() {
44+
try {
45+
Method method =
46+
JavaHttpClientTelemetryBuilder.class.getDeclaredMethod(
47+
"setEmitExperimentalHttpClientMetrics", boolean.class);
48+
method.setAccessible(true);
49+
return method;
50+
} catch (NoSuchMethodException e) {
51+
logger.log(FINE, e.getMessage(), e);
52+
return null;
53+
}
54+
}
55+
}

instrumentation/jetty-httpclient/jetty-httpclient-12.0/library/src/main/java/io/opentelemetry/instrumentation/jetty/httpclient/v12_0/JettyClientTelemetryBuilder.java

+5
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
1212
import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor;
1313
import io.opentelemetry.instrumentation.api.semconv.http.HttpClientAttributesExtractorBuilder;
14+
import io.opentelemetry.instrumentation.jetty.httpclient.v12_0.internal.Experimental;
1415
import io.opentelemetry.instrumentation.jetty.httpclient.v12_0.internal.JettyHttpClientInstrumenterBuilderFactory;
1516
import java.util.List;
1617
import java.util.Set;
@@ -101,7 +102,11 @@ public JettyClientTelemetryBuilder setKnownMethods(Set<String> knownMethods) {
101102
*
102103
* @param emitExperimentalHttpClientMetrics {@code true} if the experimental HTTP client metrics
103104
* are to be emitted.
105+
* @deprecated Use {@link
106+
* Experimental#setEmitExperimentalHttpClientMetrics(JettyClientTelemetryBuilder, boolean)}
107+
* instead.
104108
*/
109+
@Deprecated
105110
@CanIgnoreReturnValue
106111
public JettyClientTelemetryBuilder setEmitExperimentalHttpClientMetrics(
107112
boolean emitExperimentalHttpClientMetrics) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package io.opentelemetry.instrumentation.jetty.httpclient.v12_0.internal;
7+
8+
import static java.util.logging.Level.FINE;
9+
10+
import io.opentelemetry.instrumentation.jetty.httpclient.v12_0.JettyClientTelemetryBuilder;
11+
import java.lang.reflect.InvocationTargetException;
12+
import java.lang.reflect.Method;
13+
import java.util.logging.Logger;
14+
import javax.annotation.Nullable;
15+
16+
/**
17+
* This class is internal and is hence not for public use. Its APIs are unstable and can change at
18+
* any time.
19+
*/
20+
// TODO (trask) update the above javadoc similar to
21+
// https://github.com/open-telemetry/opentelemetry-java/pull/6886
22+
public class Experimental {
23+
24+
private static final Logger logger = Logger.getLogger(Experimental.class.getName());
25+
26+
@Nullable
27+
private static final Method emitExperimentalHttpClientMetricsMethod =
28+
getEmitExperimentalHttpClientMetricsMethod();
29+
30+
public void setEmitExperimentalHttpClientMetrics(
31+
JettyClientTelemetryBuilder builder, boolean emitExperimentalHttpClientMetrics) {
32+
33+
if (emitExperimentalHttpClientMetricsMethod != null) {
34+
try {
35+
emitExperimentalHttpClientMetricsMethod.invoke(builder, emitExperimentalHttpClientMetrics);
36+
} catch (IllegalAccessException | InvocationTargetException e) {
37+
logger.log(FINE, e.getMessage(), e);
38+
}
39+
}
40+
}
41+
42+
@Nullable
43+
private static Method getEmitExperimentalHttpClientMetricsMethod() {
44+
try {
45+
Method method =
46+
JettyClientTelemetryBuilder.class.getDeclaredMethod(
47+
"setEmitExperimentalHttpClientMetrics", boolean.class);
48+
method.setAccessible(true);
49+
return method;
50+
} catch (NoSuchMethodException e) {
51+
logger.log(FINE, e.getMessage(), e);
52+
return null;
53+
}
54+
}
55+
}

instrumentation/jetty-httpclient/jetty-httpclient-9.2/library/src/main/java/io/opentelemetry/instrumentation/jetty/httpclient/v9_2/JettyClientTelemetryBuilder.java

+5
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
1212
import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor;
1313
import io.opentelemetry.instrumentation.api.semconv.http.HttpClientAttributesExtractorBuilder;
14+
import io.opentelemetry.instrumentation.jetty.httpclient.v9_2.internal.Experimental;
1415
import io.opentelemetry.instrumentation.jetty.httpclient.v9_2.internal.JettyHttpClientInstrumenterBuilderFactory;
1516
import java.util.List;
1617
import java.util.Set;
@@ -101,7 +102,11 @@ public JettyClientTelemetryBuilder setKnownMethods(Set<String> knownMethods) {
101102
*
102103
* @param emitExperimentalHttpClientMetrics {@code true} if the experimental HTTP client metrics
103104
* are to be emitted.
105+
* @deprecated Use {@link
106+
* Experimental#setEmitExperimentalHttpClientMetrics(JettyClientTelemetryBuilder, boolean)}
107+
* instead.
104108
*/
109+
@Deprecated
105110
@CanIgnoreReturnValue
106111
public JettyClientTelemetryBuilder setEmitExperimentalHttpClientMetrics(
107112
boolean emitExperimentalHttpClientMetrics) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package io.opentelemetry.instrumentation.jetty.httpclient.v9_2.internal;
7+
8+
import static java.util.logging.Level.FINE;
9+
10+
import io.opentelemetry.instrumentation.jetty.httpclient.v9_2.JettyClientTelemetryBuilder;
11+
import java.lang.reflect.InvocationTargetException;
12+
import java.lang.reflect.Method;
13+
import java.util.logging.Logger;
14+
import javax.annotation.Nullable;
15+
16+
/**
17+
* This class is internal and is hence not for public use. Its APIs are unstable and can change at
18+
* any time.
19+
*/
20+
// TODO (trask) update the above javadoc similar to
21+
// https://github.com/open-telemetry/opentelemetry-java/pull/6886
22+
public class Experimental {
23+
24+
private static final Logger logger = Logger.getLogger(Experimental.class.getName());
25+
26+
@Nullable
27+
private static final Method emitExperimentalHttpClientMetricsMethod =
28+
getEmitExperimentalHttpClientMetricsMethod();
29+
30+
public void setEmitExperimentalHttpClientMetrics(
31+
JettyClientTelemetryBuilder builder, boolean emitExperimentalHttpClientMetrics) {
32+
33+
if (emitExperimentalHttpClientMetricsMethod != null) {
34+
try {
35+
emitExperimentalHttpClientMetricsMethod.invoke(builder, emitExperimentalHttpClientMetrics);
36+
} catch (IllegalAccessException | InvocationTargetException e) {
37+
logger.log(FINE, e.getMessage(), e);
38+
}
39+
}
40+
}
41+
42+
@Nullable
43+
private static Method getEmitExperimentalHttpClientMetricsMethod() {
44+
try {
45+
Method method =
46+
JettyClientTelemetryBuilder.class.getDeclaredMethod(
47+
"setEmitExperimentalHttpClientMetrics", boolean.class);
48+
method.setAccessible(true);
49+
return method;
50+
} catch (NoSuchMethodException e) {
51+
logger.log(FINE, e.getMessage(), e);
52+
return null;
53+
}
54+
}
55+
}

instrumentation/netty/netty-4.1/library/src/main/java/io/opentelemetry/instrumentation/netty/v4_1/NettyClientTelemetryBuilder.java

+11
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import io.opentelemetry.instrumentation.netty.v4.common.internal.client.NettyClientInstrumenterBuilderFactory;
1717
import io.opentelemetry.instrumentation.netty.v4.common.internal.client.NettyClientInstrumenterFactory;
1818
import io.opentelemetry.instrumentation.netty.v4.common.internal.client.NettyConnectionInstrumentationFlag;
19+
import io.opentelemetry.instrumentation.netty.v4_1.internal.Experimental;
1920
import java.util.List;
2021
import java.util.Set;
2122
import java.util.function.Function;
@@ -31,6 +32,12 @@ public final class NettyClientTelemetryBuilder {
3132
NettyClientInstrumenterBuilderFactory.create("io.opentelemetry.netty-4.1", openTelemetry);
3233
}
3334

35+
/**
36+
* @deprecated Use {@link
37+
* Experimental#setEmitExperimentalHttpClientEvents(NettyClientTelemetryBuilder, boolean)}
38+
* instead.
39+
*/
40+
@Deprecated
3441
@CanIgnoreReturnValue
3542
public NettyClientTelemetryBuilder setEmitExperimentalHttpClientEvents(
3643
boolean emitExperimentalHttpClientEvents) {
@@ -97,7 +104,11 @@ public NettyClientTelemetryBuilder setKnownMethods(Set<String> knownMethods) {
97104
*
98105
* @param emitExperimentalHttpClientMetrics {@code true} if the experimental HTTP client metrics
99106
* are to be emitted.
107+
* @deprecated Use {@link
108+
* Experimental#setEmitExperimentalHttpClientMetrics(NettyClientTelemetryBuilder, boolean)}
109+
* instead.
100110
*/
111+
@Deprecated
101112
@CanIgnoreReturnValue
102113
public NettyClientTelemetryBuilder setEmitExperimentalHttpClientMetrics(
103114
boolean emitExperimentalHttpClientMetrics) {

instrumentation/netty/netty-4.1/library/src/main/java/io/opentelemetry/instrumentation/netty/v4_1/NettyServerTelemetryBuilder.java

+5
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import io.opentelemetry.instrumentation.netty.v4.common.HttpRequestAndChannel;
1414
import io.opentelemetry.instrumentation.netty.v4.common.internal.server.HttpRequestHeadersGetter;
1515
import io.opentelemetry.instrumentation.netty.v4.common.internal.server.NettyHttpServerAttributesGetter;
16+
import io.opentelemetry.instrumentation.netty.v4_1.internal.Experimental;
1617
import io.opentelemetry.instrumentation.netty.v4_1.internal.ProtocolEventHandler;
1718
import io.opentelemetry.instrumentation.netty.v4_1.internal.server.NettyServerInstrumenterBuilderUtil;
1819
import java.util.List;
@@ -99,7 +100,11 @@ public NettyServerTelemetryBuilder setKnownMethods(Set<String> knownMethods) {
99100
*
100101
* @param emitExperimentalHttpServerMetrics {@code true} if the experimental HTTP server metrics
101102
* are to be emitted.
103+
* @deprecated Use {@link
104+
* Experimental#setEmitExperimentalHttpServerMetrics(NettyServerTelemetryBuilder, boolean)}
105+
* instead.
102106
*/
107+
@Deprecated
103108
@CanIgnoreReturnValue
104109
public NettyServerTelemetryBuilder setEmitExperimentalHttpServerMetrics(
105110
boolean emitExperimentalHttpServerMetrics) {

0 commit comments

Comments
 (0)