-
Notifications
You must be signed in to change notification settings - Fork 870
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move experimental methods out of public API
- Loading branch information
Showing
23 changed files
with
700 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
...in/java/io/opentelemetry/instrumentation/apachehttpclient/v4_3/internal/Experimental.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.instrumentation.apachehttpclient.v4_3.internal; | ||
|
||
import static java.util.logging.Level.FINE; | ||
|
||
import io.opentelemetry.instrumentation.apachehttpclient.v4_3.ApacheHttpClientTelemetryBuilder; | ||
import java.lang.reflect.InvocationTargetException; | ||
import java.lang.reflect.Method; | ||
import java.util.logging.Logger; | ||
import javax.annotation.Nullable; | ||
|
||
/** | ||
* This class is internal and is hence not for public use. Its APIs are unstable and can change at | ||
* any time. | ||
*/ | ||
// TODO (trask) update the above javadoc similar to | ||
// https://github.com/open-telemetry/opentelemetry-java/pull/6886 | ||
public class Experimental { | ||
|
||
private static final Logger logger = Logger.getLogger(Experimental.class.getName()); | ||
|
||
@Nullable | ||
private static final Method emitExperimentalTelemetryMethod = | ||
getEmitExperimentalTelemetryMethod(); | ||
|
||
public void setEmitExperimentalTelemetry( | ||
ApacheHttpClientTelemetryBuilder builder, boolean emitExperimentalTelemetry) { | ||
|
||
if (emitExperimentalTelemetryMethod != null) { | ||
try { | ||
emitExperimentalTelemetryMethod.invoke(builder, emitExperimentalTelemetry); | ||
} catch (IllegalAccessException | InvocationTargetException e) { | ||
logger.log(FINE, e.getMessage(), e); | ||
} | ||
} | ||
} | ||
|
||
@Nullable | ||
private static Method getEmitExperimentalTelemetryMethod() { | ||
try { | ||
Method method = | ||
ApacheHttpClientTelemetryBuilder.class.getDeclaredMethod( | ||
"setEmitExperimentalHttpClientMetrics", boolean.class); | ||
method.setAccessible(true); | ||
return method; | ||
} catch (NoSuchMethodException e) { | ||
logger.log(FINE, e.getMessage(), e); | ||
return null; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
...rary/src/main/java/io/opentelemetry/instrumentation/httpclient/internal/Experimental.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.instrumentation.httpclient.internal; | ||
|
||
import static java.util.logging.Level.FINE; | ||
|
||
import io.opentelemetry.instrumentation.httpclient.JavaHttpClientTelemetryBuilder; | ||
import java.lang.reflect.InvocationTargetException; | ||
import java.lang.reflect.Method; | ||
import java.util.logging.Logger; | ||
import javax.annotation.Nullable; | ||
|
||
/** | ||
* This class is internal and is hence not for public use. Its APIs are unstable and can change at | ||
* any time. | ||
*/ | ||
// TODO (trask) update the above javadoc similar to | ||
// https://github.com/open-telemetry/opentelemetry-java/pull/6886 | ||
public class Experimental { | ||
|
||
private static final Logger logger = Logger.getLogger(Experimental.class.getName()); | ||
|
||
@Nullable | ||
private static final Method emitExperimentalTelemetryMethod = | ||
getEmitExperimentalTelemetryMethod(); | ||
|
||
public void setEmitExperimentalTelemetry( | ||
JavaHttpClientTelemetryBuilder builder, boolean emitExperimentalTelemetry) { | ||
|
||
if (emitExperimentalTelemetryMethod != null) { | ||
try { | ||
emitExperimentalTelemetryMethod.invoke(builder, emitExperimentalTelemetry); | ||
} catch (IllegalAccessException | InvocationTargetException e) { | ||
logger.log(FINE, e.getMessage(), e); | ||
} | ||
} | ||
} | ||
|
||
@Nullable | ||
private static Method getEmitExperimentalTelemetryMethod() { | ||
try { | ||
Method method = | ||
JavaHttpClientTelemetryBuilder.class.getDeclaredMethod( | ||
"setEmitExperimentalHttpClientMetrics", boolean.class); | ||
method.setAccessible(true); | ||
return method; | ||
} catch (NoSuchMethodException e) { | ||
logger.log(FINE, e.getMessage(), e); | ||
return null; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
...n/java/io/opentelemetry/instrumentation/jetty/httpclient/v12_0/internal/Experimental.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.instrumentation.jetty.httpclient.v12_0.internal; | ||
|
||
import static java.util.logging.Level.FINE; | ||
|
||
import io.opentelemetry.instrumentation.jetty.httpclient.v12_0.JettyClientTelemetryBuilder; | ||
import java.lang.reflect.InvocationTargetException; | ||
import java.lang.reflect.Method; | ||
import java.util.logging.Logger; | ||
import javax.annotation.Nullable; | ||
|
||
/** | ||
* This class is internal and is hence not for public use. Its APIs are unstable and can change at | ||
* any time. | ||
*/ | ||
// TODO (trask) update the above javadoc similar to | ||
// https://github.com/open-telemetry/opentelemetry-java/pull/6886 | ||
public class Experimental { | ||
|
||
private static final Logger logger = Logger.getLogger(Experimental.class.getName()); | ||
|
||
@Nullable | ||
private static final Method emitExperimentalTelemetryMethod = | ||
getEmitExperimentalTelemetryMethod(); | ||
|
||
public void setEmitExperimentalTelemetry( | ||
JettyClientTelemetryBuilder builder, boolean emitExperimentalTelemetry) { | ||
|
||
if (emitExperimentalTelemetryMethod != null) { | ||
try { | ||
emitExperimentalTelemetryMethod.invoke(builder, emitExperimentalTelemetry); | ||
} catch (IllegalAccessException | InvocationTargetException e) { | ||
logger.log(FINE, e.getMessage(), e); | ||
} | ||
} | ||
} | ||
|
||
@Nullable | ||
private static Method getEmitExperimentalTelemetryMethod() { | ||
try { | ||
Method method = | ||
JettyClientTelemetryBuilder.class.getDeclaredMethod( | ||
"setEmitExperimentalHttpClientMetrics", boolean.class); | ||
method.setAccessible(true); | ||
return method; | ||
} catch (NoSuchMethodException e) { | ||
logger.log(FINE, e.getMessage(), e); | ||
return null; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
...in/java/io/opentelemetry/instrumentation/jetty/httpclient/v9_2/internal/Experimental.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.instrumentation.jetty.httpclient.v9_2.internal; | ||
|
||
import static java.util.logging.Level.FINE; | ||
|
||
import io.opentelemetry.instrumentation.jetty.httpclient.v9_2.JettyClientTelemetryBuilder; | ||
import java.lang.reflect.InvocationTargetException; | ||
import java.lang.reflect.Method; | ||
import java.util.logging.Logger; | ||
import javax.annotation.Nullable; | ||
|
||
/** | ||
* This class is internal and is hence not for public use. Its APIs are unstable and can change at | ||
* any time. | ||
*/ | ||
// TODO (trask) update the above javadoc similar to | ||
// https://github.com/open-telemetry/opentelemetry-java/pull/6886 | ||
public class Experimental { | ||
|
||
private static final Logger logger = Logger.getLogger(Experimental.class.getName()); | ||
|
||
@Nullable | ||
private static final Method emitExperimentalTelemetryMethod = | ||
getEmitExperimentalTelemetryMethod(); | ||
|
||
public void setEmitExperimentalTelemetry( | ||
JettyClientTelemetryBuilder builder, boolean emitExperimentalTelemetry) { | ||
|
||
if (emitExperimentalTelemetryMethod != null) { | ||
try { | ||
emitExperimentalTelemetryMethod.invoke(builder, emitExperimentalTelemetry); | ||
} catch (IllegalAccessException | InvocationTargetException e) { | ||
logger.log(FINE, e.getMessage(), e); | ||
} | ||
} | ||
} | ||
|
||
@Nullable | ||
private static Method getEmitExperimentalTelemetryMethod() { | ||
try { | ||
Method method = | ||
JettyClientTelemetryBuilder.class.getDeclaredMethod( | ||
"setEmitExperimentalHttpClientMetrics", boolean.class); | ||
method.setAccessible(true); | ||
return method; | ||
} catch (NoSuchMethodException e) { | ||
logger.log(FINE, e.getMessage(), e); | ||
return null; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.