Remove Glassfish instrumentation (#176)

This commit is contained in:
Trask Stalnaker 2020-02-21 11:01:17 -08:00 committed by GitHub
parent 23f6e1513d
commit ebf3d78274
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 1 additions and 76 deletions

View File

@ -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<? super TypeDescription> typeMatcher() {
return ElementMatchers.named(
"com.sun.enterprise.v3.server.APIClassLoaderServiceImpl$APIClassLoader");
}
@Override
public Map<? extends ElementMatcher<? super MethodDescription>, 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;
}
}
}
}
}

View File

@ -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'

View File

@ -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