Use isHelperClass over additionalHelperClassNames
MODIFY
instrumentation/apache-camel-2.20/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachecamel/ApacheCamelInstrumentationModule.java
instrumentation/apache-camel-2.20/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachecamel/ApacheCamelInstrumentationModule.java
@@ -39,11 +39,8 @@ public class ApacheCamelInstrumentationModule extends InstrumentationModule {
}
@Override
- public String[] additionalHelperClassNames() {
- return new String[] {
- "io.opentelemetry.extension.aws.AwsXrayPropagator",
- "io.opentelemetry.extension.aws.AwsXrayPropagator$1"
- };
+ public boolean isHelperClass(String className) {
+ return className.startsWith("io.opentelemetry.extension.aws.");
}
public static class CamelContextInstrumentation implements TypeInstrumentation {

MODIFY
instrumentation/aws-lambda-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/awslambda/v1_0/AwsLambdaInstrumentationModule.java
instrumentation/aws-lambda-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/awslambda/v1_0/AwsLambdaInstrumentationModule.java
@@ -19,11 +19,8 @@ public class AwsLambdaInstrumentationModule extends InstrumentationModule {
}
@Override
- public String[] additionalHelperClassNames() {
- return new String[] {
- "io.opentelemetry.extension.aws.AwsXrayPropagator",
- "io.opentelemetry.extension.aws.AwsXrayPropagator$1"
- };
+ public boolean isHelperClass(String className) {
+ return className.startsWith("io.opentelemetry.extension.aws.");
}
@Override

MODIFY
instrumentation/aws-sdk/aws-sdk-1.11/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/awssdk/v1_11/AwsSdkInstrumentationModule.java
instrumentation/aws-sdk/aws-sdk-1.11/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/awssdk/v1_11/AwsSdkInstrumentationModule.java
@@ -19,11 +19,8 @@ public class AwsSdkInstrumentationModule extends InstrumentationModule {
}
@Override
- public String[] additionalHelperClassNames() {
- return new String[] {
- "io.opentelemetry.extension.aws.AwsXrayPropagator",
- "io.opentelemetry.extension.aws.AwsXrayPropagator$1"
- };
+ public boolean isHelperClass(String className) {
+ return className.startsWith("io.opentelemetry.extension.aws.");
}
@Override

MODIFY
instrumentation/aws-sdk/aws-sdk-2.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/awssdk/v2_2/AwsSdkInstrumentationModule.java
instrumentation/aws-sdk/aws-sdk-2.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/awssdk/v2_2/AwsSdkInstrumentationModule.java
@@ -25,11 +25,8 @@ public class AwsSdkInstrumentationModule extends InstrumentationModule {
}
@Override
- public String[] additionalHelperClassNames() {
- return new String[] {
- "io.opentelemetry.extension.aws.AwsXrayPropagator",
- "io.opentelemetry.extension.aws.AwsXrayPropagator$1"
- };
+ public boolean isHelperClass(String className) {
+ return className.startsWith("io.opentelemetry.extension.aws.");
}
/**

MODIFY
instrumentation/couchbase/couchbase-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/couchbase/v2_0/CouchbaseInstrumentationModule.java
instrumentation/couchbase/couchbase-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/couchbase/v2_0/CouchbaseInstrumentationModule.java
@@ -19,10 +19,8 @@ public class CouchbaseInstrumentationModule extends InstrumentationModule {
}
@Override
- protected String[] additionalHelperClassNames() {
- return new String[] {
- "rx.__OpenTelemetryTracingUtil",
- };
+ public boolean isHelperClass(String className) {
+ return className.equals("rx.__OpenTelemetryTracingUtil");
}
@Override

MODIFY
instrumentation/hystrix-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/hystrix/HystrixInstrumentationModule.java
instrumentation/hystrix-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/hystrix/HystrixInstrumentationModule.java
@@ -39,10 +39,8 @@ public class HystrixInstrumentationModule extends InstrumentationModule {
}
@Override
- protected String[] additionalHelperClassNames() {
- return new String[] {
- "rx.__OpenTelemetryTracingUtil",
- };
+ public boolean isHelperClass(String className) {
+ return className.equals("rx.__OpenTelemetryTracingUtil");
}
@Override

MODIFY
instrumentation/internal/internal-class-loader/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/internal/classloader/ClassLoaderInstrumentationModule.java
instrumentation/internal/internal-class-loader/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/internal/classloader/ClassLoaderInstrumentationModule.java
@@ -19,8 +19,8 @@ public class ClassLoaderInstrumentationModule extends InstrumentationModule {
}
@Override
- protected String[] additionalHelperClassNames() {
- return new String[] {"io.opentelemetry.javaagent.tooling.Constants"};
+ public boolean isHelperClass(String className) {
+ return className.equals("io.opentelemetry.javaagent.tooling.Constants");
}
@Override

MODIFY
instrumentation/kotlinx-coroutines/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/kotlinxcoroutines/KotlinCoroutinesInstrumentationModule.java
instrumentation/kotlinx-coroutines/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/kotlinxcoroutines/KotlinCoroutinesInstrumentationModule.java
@@ -29,12 +29,8 @@ public class KotlinCoroutinesInstrumentationModule extends InstrumentationModule
}
@Override
- public String[] additionalHelperClassNames() {
- return new String[] {
- "io.opentelemetry.extension.kotlin.ContextExtensionsKt",
- "io.opentelemetry.extension.kotlin.KotlinContextElement",
- "io.opentelemetry.extension.kotlin.KotlinContextElement$1"
- };
+ public boolean isHelperClass(String className) {
+ return className.startsWith("io.opentelemetry.extension.kotlin.");
}
@Override

MODIFY
javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/InstrumentationModule.java
javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/InstrumentationModule.java
@@ -322,6 +322,9 @@ public abstract class InstrumentationModule {
* not located in instrumentation packages described in {@link InstrumentationClassPredicate} and
* {@link #isHelperClass(String)} (and not automatically detected by muzzle). These additional
* classes will be injected into the application classloader first.
+ *
+ * <p>Implementing {@link #isHelperClass(String)} is generally simpler and less error-prone
+ * compared to implementing this method.
*/
protected String[] additionalHelperClassNames() {
return EMPTY;

MODIFY
testing-common/integration-tests/src/main/java/context/ContextTestInstrumentationModule.java
testing-common/integration-tests/src/main/java/context/ContextTestInstrumentationModule.java
@@ -38,8 +38,8 @@ public class ContextTestInstrumentationModule extends InstrumentationModule {
}
@Override
- protected String[] additionalHelperClassNames() {
- return new String[] {getClass().getName() + "$Context"};
+ public boolean isHelperClass(String className) {
+ return className.equals(getClass().getName() + "$Context");
}
@Override

Use isHelperClass over additionalHelperClassNames (#2796)