Explicitly inject on httpclientbuilder's classloader
MODIFY
dd-java-agent-ittests/src/test/java/com/datadoghq/agent/integration/ApacheHTTPClientTest.java
dd-java-agent-ittests/src/test/java/com/datadoghq/agent/integration/ApacheHTTPClientTest.java
@@ -6,14 +6,19 @@ import org.apache.http.impl.client.HttpClientBuilder;
import org.junit.Test;
public class ApacheHTTPClientTest {
-
- @Test
- public void test() throws Exception {
+ static {
+ try {
// Since the HttpClientBuilder initializer doesn't work, invoke manually.
Class.forName("com.datadoghq.agent.InstrumentationRulesManager")
- .getMethod("registerClassLoad")
- .invoke(null);
+ .getMethod("registerClassLoad", Object.class)
+ .invoke(null, Thread.currentThread().getContextClassLoader());
+ } catch (Exception e) {
+ System.err.println("clinit error: " + e.getMessage());
+ }
+ }
+ @Test
+ public void test() throws Exception {
final HttpClientBuilder builder = HttpClientBuilder.create();
assertThat(builder.getClass().getSimpleName()).isEqualTo("TracingHttpClientBuilder");
}

Explicitly inject on httpclientbuilder's classloader