Add debug logging to flaky apache async client tests (#13460)
This commit is contained in:
parent
dfe392e741
commit
fec887880d
|
@ -17,5 +17,6 @@ dependencies {
|
|||
tasks {
|
||||
withType<Test>().configureEach {
|
||||
systemProperty("testLatestDeps", findProperty("testLatestDeps") as Boolean)
|
||||
systemProperty("otel.instrumentation.apache-httpclient-5.debug", "true")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
package io.opentelemetry.javaagent.instrumentation.apachehttpclient.v5_0;
|
||||
|
||||
import com.google.auto.service.AutoService;
|
||||
import io.opentelemetry.javaagent.bootstrap.internal.AgentInstrumentationConfig;
|
||||
import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule;
|
||||
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
|
||||
import java.util.Arrays;
|
||||
|
@ -20,6 +21,15 @@ public class ApacheHttpClientInstrumentationModule extends InstrumentationModule
|
|||
|
||||
@Override
|
||||
public List<TypeInstrumentation> typeInstrumentations() {
|
||||
boolean debug =
|
||||
AgentInstrumentationConfig.get()
|
||||
.getBoolean("otel.instrumentation.apache-httpclient-5.debug", false);
|
||||
if (debug) {
|
||||
return Arrays.asList(
|
||||
new ApacheHttpClientInstrumentation(),
|
||||
new ApacheHttpAsyncClientInstrumentation(),
|
||||
new IoReactorDebugInstrumentation());
|
||||
}
|
||||
return Arrays.asList(
|
||||
new ApacheHttpClientInstrumentation(), new ApacheHttpAsyncClientInstrumentation());
|
||||
}
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* Copyright The OpenTelemetry Authors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package io.opentelemetry.javaagent.instrumentation.apachehttpclient.v5_0;
|
||||
|
||||
import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.implementsInterface;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.namedOneOf;
|
||||
|
||||
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
|
||||
import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer;
|
||||
import net.bytebuddy.asm.Advice;
|
||||
import net.bytebuddy.description.type.TypeDescription;
|
||||
import net.bytebuddy.matcher.ElementMatcher;
|
||||
|
||||
public class IoReactorDebugInstrumentation implements TypeInstrumentation {
|
||||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return implementsInterface(named("org.apache.hc.core5.reactor.IOReactor"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void transform(TypeTransformer transformer) {
|
||||
transformer.applyAdviceToMethod(
|
||||
namedOneOf("close", "initiateShutdown"), this.getClass().getName() + "$CloseAdvice");
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public static class CloseAdvice {
|
||||
|
||||
@SuppressWarnings("SystemOut")
|
||||
@Advice.OnMethodEnter(suppress = Throwable.class)
|
||||
public static void methodEnter(@Advice.This Object instance) {
|
||||
System.err.println("closing i/o reactor " + instance);
|
||||
new Exception().printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue