From ebf3d7827495667e25346348ea41146ea922d2b5 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Fri, 21 Feb 2020 11:01:17 -0800 Subject: [PATCH] Remove Glassfish instrumentation (#176) --- .../glassfish/GlassFishInstrumentation.java | 66 ------------------- .../glassfish-testing.gradle} | 9 --- .../test/groovy/GlassFishServerTest.groovy | 0 .../groovy/GrizzlyTestInstrumentation.java | 0 .../src/test/groovy/TestServlets.java | 0 .../src/test/resources/WEB-INF/web.xml | 0 .../src/test/resources/error.jsp | 0 settings.gradle | 2 +- 8 files changed, 1 insertion(+), 76 deletions(-) delete mode 100644 instrumentation/glassfish-3.0/src/main/java/io/opentelemetry/auto/instrumentation/glassfish/GlassFishInstrumentation.java rename instrumentation/{glassfish-3.0/glassfish-3.0.gradle => servlet/glassfish-testing/glassfish-testing.gradle} (78%) rename instrumentation/{glassfish-3.0 => servlet/glassfish-testing}/src/test/groovy/GlassFishServerTest.groovy (100%) rename instrumentation/{glassfish-3.0 => servlet/glassfish-testing}/src/test/groovy/GrizzlyTestInstrumentation.java (100%) rename instrumentation/{glassfish-3.0 => servlet/glassfish-testing}/src/test/groovy/TestServlets.java (100%) rename instrumentation/{glassfish-3.0 => servlet/glassfish-testing}/src/test/resources/WEB-INF/web.xml (100%) rename instrumentation/{glassfish-3.0 => servlet/glassfish-testing}/src/test/resources/error.jsp (100%) diff --git a/instrumentation/glassfish-3.0/src/main/java/io/opentelemetry/auto/instrumentation/glassfish/GlassFishInstrumentation.java b/instrumentation/glassfish-3.0/src/main/java/io/opentelemetry/auto/instrumentation/glassfish/GlassFishInstrumentation.java deleted file mode 100644 index f5a79a5796..0000000000 --- a/instrumentation/glassfish-3.0/src/main/java/io/opentelemetry/auto/instrumentation/glassfish/GlassFishInstrumentation.java +++ /dev/null @@ -1,66 +0,0 @@ -package io.opentelemetry.auto.instrumentation.glassfish; - -import static java.util.Collections.singletonMap; -import static net.bytebuddy.matcher.ElementMatchers.isMethod; -import static net.bytebuddy.matcher.ElementMatchers.named; -import static net.bytebuddy.matcher.ElementMatchers.takesArguments; - -import com.google.auto.service.AutoService; -import io.opentelemetry.auto.tooling.Constants; -import io.opentelemetry.auto.tooling.Instrumenter; -import java.util.Map; -import lombok.extern.slf4j.Slf4j; -import net.bytebuddy.asm.Advice; -import net.bytebuddy.description.method.MethodDescription; -import net.bytebuddy.description.type.TypeDescription; -import net.bytebuddy.matcher.ElementMatcher; -import net.bytebuddy.matcher.ElementMatchers; - -/** - * This instrumenter prevents a mechanism from GlassFish classloader to produces a class not found - * exception in our tracer. Link to the GH issue: - * https://github.com/eclipse-ee4j/glassfish/issues/22566 If a class loading is attempted, as an - * example, as a resource and is it not found, then it is blacklisted. Successive attempts to load a - * class as a class (not a resource) will fail because the class is not even tried. We hook into the - * blacklisting method to avoid specific namespaces to be blacklisted. - */ -@Slf4j -@AutoService(Instrumenter.class) -public final class GlassFishInstrumentation extends Instrumenter.Default { - - public GlassFishInstrumentation() { - super("glassfish"); - } - - @Override - public String[] helperClassNames() { - return new String[] {Constants.class.getName()}; - } - - @Override - public ElementMatcher typeMatcher() { - return ElementMatchers.named( - "com.sun.enterprise.v3.server.APIClassLoaderServiceImpl$APIClassLoader"); - } - - @Override - public Map, String> transformers() { - return singletonMap( - isMethod().and(named("addToBlackList")).and(takesArguments(1)), - GlassFishInstrumentation.class.getName() + "$AvoidGlassFishBlacklistAdvice"); - } - - public static class AvoidGlassFishBlacklistAdvice { - - @Advice.OnMethodEnter(suppress = Throwable.class) - public static void preventBlacklistingOfTracerClasses( - @Advice.Argument(value = 0, readOnly = false) String name) { - for (final String prefix : Constants.BOOTSTRAP_PACKAGE_PREFIXES) { - if (name.startsWith(prefix)) { - name = "__opentelemetry_auto_no_blacklist." + name; - break; - } - } - } - } -} diff --git a/instrumentation/glassfish-3.0/glassfish-3.0.gradle b/instrumentation/servlet/glassfish-testing/glassfish-testing.gradle similarity index 78% rename from instrumentation/glassfish-3.0/glassfish-3.0.gradle rename to instrumentation/servlet/glassfish-testing/glassfish-testing.gradle index 84fbff8a5e..f9d378d20a 100644 --- a/instrumentation/glassfish-3.0/glassfish-3.0.gradle +++ b/instrumentation/servlet/glassfish-testing/glassfish-testing.gradle @@ -2,15 +2,6 @@ ext { maxJavaVersionForTests = JavaVersion.VERSION_1_8 } -muzzle { - pass { - group = 'org.glassfish.main.extras' - module = 'glassfish-embedded-all' - versions = "[3.0,)" - assertInverse = true - } -} - apply from: "${rootDir}/gradle/java.gradle" apply plugin: 'org.unbroken-dome.test-sets' diff --git a/instrumentation/glassfish-3.0/src/test/groovy/GlassFishServerTest.groovy b/instrumentation/servlet/glassfish-testing/src/test/groovy/GlassFishServerTest.groovy similarity index 100% rename from instrumentation/glassfish-3.0/src/test/groovy/GlassFishServerTest.groovy rename to instrumentation/servlet/glassfish-testing/src/test/groovy/GlassFishServerTest.groovy diff --git a/instrumentation/glassfish-3.0/src/test/groovy/GrizzlyTestInstrumentation.java b/instrumentation/servlet/glassfish-testing/src/test/groovy/GrizzlyTestInstrumentation.java similarity index 100% rename from instrumentation/glassfish-3.0/src/test/groovy/GrizzlyTestInstrumentation.java rename to instrumentation/servlet/glassfish-testing/src/test/groovy/GrizzlyTestInstrumentation.java diff --git a/instrumentation/glassfish-3.0/src/test/groovy/TestServlets.java b/instrumentation/servlet/glassfish-testing/src/test/groovy/TestServlets.java similarity index 100% rename from instrumentation/glassfish-3.0/src/test/groovy/TestServlets.java rename to instrumentation/servlet/glassfish-testing/src/test/groovy/TestServlets.java diff --git a/instrumentation/glassfish-3.0/src/test/resources/WEB-INF/web.xml b/instrumentation/servlet/glassfish-testing/src/test/resources/WEB-INF/web.xml similarity index 100% rename from instrumentation/glassfish-3.0/src/test/resources/WEB-INF/web.xml rename to instrumentation/servlet/glassfish-testing/src/test/resources/WEB-INF/web.xml diff --git a/instrumentation/glassfish-3.0/src/test/resources/error.jsp b/instrumentation/servlet/glassfish-testing/src/test/resources/error.jsp similarity index 100% rename from instrumentation/glassfish-3.0/src/test/resources/error.jsp rename to instrumentation/servlet/glassfish-testing/src/test/resources/error.jsp diff --git a/settings.gradle b/settings.gradle index c226bd06fb..151f6fe1e3 100644 --- a/settings.gradle +++ b/settings.gradle @@ -65,7 +65,6 @@ include ':instrumentation:elasticsearch:transport-5.0' include ':instrumentation:elasticsearch:transport-5.3' include ':instrumentation:elasticsearch:transport-6.0' include ':instrumentation:finatra-2.9' -include ':instrumentation:glassfish-3.0' include ':instrumentation:google-http-client-1.19' include ':instrumentation:grizzly-2.0' include ':instrumentation:grpc-1.5' @@ -122,6 +121,7 @@ include ':instrumentation:reactor-core-3.1' include ':instrumentation:rmi' include ':instrumentation:rxjava-1.0' include ':instrumentation:servlet' +include ':instrumentation:servlet:glassfish-testing' include ':instrumentation:servlet:request-2.3' include ':instrumentation:servlet:request-3.0' // FIXME this instrumentation relied on scope listener