Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 0cff2dd

Browse files
committedDec 7, 2024·
Move experimental things out of public api
1 parent 80ccda1 commit 0cff2dd

File tree

22 files changed

+621
-0
lines changed

22 files changed

+621
-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,52 @@
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+
return ApacheHttpClientTelemetryBuilder.class.getMethod(
46+
"setEmitExperimentalHttpClientMetrics", boolean.class);
47+
} catch (NoSuchMethodException e) {
48+
logger.log(FINE, e.getMessage(), e);
49+
return null;
50+
}
51+
}
52+
}

‎instrumentation/apache-httpclient/apache-httpclient-5.2/library/src/main/java/io/opentelemetry/instrumentation/apachehttpclient/v5_2/ApacheHttpClient5TelemetryBuilder.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.v5_2.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;
@@ -90,7 +91,11 @@ public ApacheHttpClient5TelemetryBuilder setKnownMethods(Set<String> knownMethod
9091
*
9192
* @param emitExperimentalHttpClientMetrics {@code true} if the experimental HTTP client metrics
9293
* are to be emitted.
94+
* @deprecated Use {@link
95+
* Experimental#setEmitExperimentalHttpClientMetrics(ApacheHttpClient5TelemetryBuilder,
96+
* boolean)} instead.
9397
*/
98+
@Deprecated
9499
@CanIgnoreReturnValue
95100
public ApacheHttpClient5TelemetryBuilder setEmitExperimentalHttpClientMetrics(
96101
boolean emitExperimentalHttpClientMetrics) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package io.opentelemetry.instrumentation.apachehttpclient.v5_2.internal;
7+
8+
import static java.util.logging.Level.FINE;
9+
10+
import io.opentelemetry.instrumentation.apachehttpclient.v5_2.ApacheHttpClient5TelemetryBuilder;
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+
ApacheHttpClient5TelemetryBuilder 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+
return ApacheHttpClient5TelemetryBuilder.class.getMethod(
46+
"setEmitExperimentalHttpClientMetrics", boolean.class);
47+
} catch (NoSuchMethodException e) {
48+
logger.log(FINE, e.getMessage(), e);
49+
return null;
50+
}
51+
}
52+
}

‎instrumentation/armeria/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/ArmeriaTelemetryBuilder.java

+5
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import io.opentelemetry.instrumentation.api.semconv.http.HttpServerAttributesExtractorBuilder;
2121
import io.opentelemetry.instrumentation.armeria.v1_3.internal.ArmeriaInstrumenterBuilderFactory;
2222
import io.opentelemetry.instrumentation.armeria.v1_3.internal.ArmeriaInstrumenterBuilderUtil;
23+
import io.opentelemetry.instrumentation.armeria.v1_3.internal.Experimental;
2324
import java.util.List;
2425
import java.util.Set;
2526
import java.util.function.Function;
@@ -201,7 +202,11 @@ public ArmeriaTelemetryBuilder setKnownMethods(Set<String> knownMethods) {
201202
*
202203
* @param emitExperimentalHttpClientMetrics {@code true} if the experimental HTTP client metrics
203204
* are to be emitted.
205+
* @deprecated Use {@link
206+
* Experimental#setEmitExperimentalHttpClientMetrics(ArmeriaTelemetryBuilder, boolean)}
207+
* instead.
204208
*/
209+
@Deprecated
205210
@CanIgnoreReturnValue
206211
public ArmeriaTelemetryBuilder setEmitExperimentalHttpClientMetrics(
207212
boolean emitExperimentalHttpClientMetrics) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package io.opentelemetry.instrumentation.armeria.v1_3.internal;
7+
8+
import static java.util.logging.Level.FINE;
9+
10+
import io.opentelemetry.instrumentation.armeria.v1_3.ArmeriaTelemetryBuilder;
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+
ArmeriaTelemetryBuilder 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+
return ArmeriaTelemetryBuilder.class.getMethod(
46+
"setEmitExperimentalHttpClientMetrics", boolean.class);
47+
} catch (NoSuchMethodException e) {
48+
logger.log(FINE, e.getMessage(), e);
49+
return null;
50+
}
51+
}
52+
}

‎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,52 @@
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+
return JavaHttpClientTelemetryBuilder.class.getMethod(
46+
"setEmitExperimentalHttpClientMetrics", boolean.class);
47+
} catch (NoSuchMethodException e) {
48+
logger.log(FINE, e.getMessage(), e);
49+
return null;
50+
}
51+
}
52+
}

‎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,52 @@
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+
return JettyClientTelemetryBuilder.class.getMethod(
46+
"setEmitExperimentalHttpClientMetrics", boolean.class);
47+
} catch (NoSuchMethodException e) {
48+
logger.log(FINE, e.getMessage(), e);
49+
return null;
50+
}
51+
}
52+
}

‎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) {

0 commit comments

Comments
 (0)
Please sign in to comment.