Muzzle should recognise mismatch on unimplemented abstract methods at runtime
MODIFY
javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/muzzle/ReferenceCreationPredicate.java
javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/muzzle/ReferenceCreationPredicate.java
@@ -12,24 +12,25 @@ package io.opentelemetry.javaagent.tooling.muzzle;
* create references from the method advice and helper classes.
*/
final class ReferenceCreationPredicate {
- private static final String REFERENCE_CREATION_PACKAGE = "io.opentelemetry.instrumentation.";
+ // non-shaded packages
+ private static final String AUTO_INSTRUMENTATION_PACKAGE =
+ "io.opentelemetry.instrumentation.auto.";
+ private static final String JAVA_AGENT_TOOLING_PACKAGE = "io.opentelemetry.javaagent.tooling.";
+ private static final String AUTO_INSTRUMENTATION_API_PACKAGE =
+ "io.opentelemetry.instrumentation.auto.api.";
- private static final String JAVA_AGENT_PACKAGE = "io.opentelemetry.javaagent.tooling.";
-
- private static final String[] REFERENCE_CREATION_PACKAGE_EXCLUDES = {
- "io.opentelemetry.instrumentation.api.", "io.opentelemetry.instrumentation.auto.api."
- };
+ // shaded packages
+ private static final String LIBRARY_INSTRUMENTATION_PACKAGE = "io.opentelemetry.instrumentation.";
+ private static final String INSTRUMENTATION_API_PACKAGE = "io.opentelemetry.instrumentation.api.";
static boolean shouldCreateReferenceFor(String className) {
- if (!className.startsWith(REFERENCE_CREATION_PACKAGE)) {
- return className.startsWith(JAVA_AGENT_PACKAGE);
- }
- for (String exclude : REFERENCE_CREATION_PACKAGE_EXCLUDES) {
- if (className.startsWith(exclude)) {
+ if (className.startsWith(INSTRUMENTATION_API_PACKAGE)
+ || className.startsWith(AUTO_INSTRUMENTATION_API_PACKAGE)) {
return false;
}
- }
- return true;
+ return className.startsWith(AUTO_INSTRUMENTATION_PACKAGE)
+ || className.startsWith(JAVA_AGENT_TOOLING_PACKAGE)
+ || className.startsWith(LIBRARY_INSTRUMENTATION_PACKAGE);
}
private ReferenceCreationPredicate() {}

MODIFY
javaagent-tooling/src/test/groovy/io/opentelemetry/javaagent/tooling/muzzle/ReferenceCreationPredicateTest.groovy
javaagent-tooling/src/test/groovy/io/opentelemetry/javaagent/tooling/muzzle/ReferenceCreationPredicateTest.groovy
@@ -16,8 +16,9 @@ class ReferenceCreationPredicateTest extends Specification {
where:
desc | className
- "Instrumentation class" | "io.opentelemetry.instrumentation.some_instrumentation.Advice"
+ "auto instrumentation class" | "io.opentelemetry.instrumentation.auto.some_instrumentation.Advice"
"javaagent-tooling class" | "io.opentelemetry.javaagent.tooling.Constants"
+ "library instrumentation class" | "io.opentelemetry.instrumentation.LibraryClass"
}
@Unroll

Muzzle should recognise mismatch on unimplemented abstract methods at runtime (#1357)