Browse Source

Fix ForkJoinPool sometimes not instrumented (#3293)

Trask Stalnaker 3 years ago
parent
commit
8be100637a

+ 6 - 0
javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/AgentInstaller.java

@@ -36,6 +36,7 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.concurrent.ForkJoinPool;
 import java.util.stream.Stream;
 import java.util.stream.StreamSupport;
 import net.bytebuddy.agent.builder.AgentBuilder;
@@ -86,6 +87,11 @@ public class AgentInstaller {
     // loading java.lang.reflect.Proxy early here still allows it to be retransformed by the
     // internal-proxy instrumentation module after the bytebuddy transformer is set up
     Proxy.class.getName();
+
+    // caffeine can trigger first access of ForkJoinPool under transform(), which leads ForkJoinPool
+    // not to get transformed itself.
+    // loading it early here still allows it to be retransformed as part of agent installation below
+    ForkJoinPool.class.getName();
   }
 
   public static void installBytebuddyAgent(Instrumentation inst) {