Enable tracing of jax-rs client in sun package
MODIFY
dd-java-agent/agent-tooling/src/main/java/datadog/trace/agent/tooling/AgentInstaller.java
dd-java-agent/agent-tooling/src/main/java/datadog/trace/agent/tooling/AgentInstaller.java
@@ -107,7 +107,12 @@ public class AgentInstaller {
// Working around until a long-term fix for modules can be
// put in place.
.and(not(named("java.util.logging.LogManager$Cleaner")))))))
- .or(nameStartsWith("com.sun.").and(not(nameStartsWith("com.sun.messaging."))))
+ .or(
+ nameStartsWith("com.sun.")
+ .and(
+ not(
+ nameStartsWith("com.sun.messaging.")
+ .or(nameStartsWith("com.sun.jersey.api.client")))))
.or(
nameStartsWith("sun.")
.and(

MODIFY
dd-java-agent/instrumentation/jax-rs-client/jax-rs-client-1/src/main/java/datadog/trace/instrumentation/jaxrs/v1/JaxRsClientV1Instrumentation.java
dd-java-agent/instrumentation/jax-rs-client/jax-rs-client-1/src/main/java/datadog/trace/instrumentation/jaxrs/v1/JaxRsClientV1Instrumentation.java
@@ -41,9 +41,7 @@ public final class JaxRsClientV1Instrumentation extends Instrumenter.Default {
"datadog.trace.agent.decorator.BaseDecorator",
"datadog.trace.agent.decorator.ClientDecorator",
"datadog.trace.agent.decorator.HttpClientDecorator",
- packageName + ".JaxRsClientDecorator",
- packageName + ".ClientTracingFeature",
- packageName + ".ClientTracingFilter",
+ packageName + ".JaxRsClientV1Decorator",
packageName + ".InjectAdapter",
};
}
@@ -53,7 +51,9 @@ public final class JaxRsClientV1Instrumentation extends Instrumenter.Default {
System.out.println("######### REGISTERING");
return singletonMap(
named("handle")
- .and(takesArgument(0, safeHasSuperType(named("com.sun.jersey.api.client.ClientRequest"))))
+ .and(
+ takesArgument(
+ 0, safeHasSuperType(named("com.sun.jersey.api.client.ClientRequest"))))
.and(returns(safeHasSuperType(named("com.sun.jersey.api.client.ClientResponse")))),
HandleAdvice.class.getName());
}
@@ -65,8 +65,6 @@ public final class JaxRsClientV1Instrumentation extends Instrumenter.Default {
@Advice.Argument(value = 0) final ClientRequest request,
@Advice.This final ClientHandler thisObj) {
- System.out.println("############ ON HANDLE ENTER");
-
// WARNING: this might be a chain...so we only have to trace the first in the chain.
boolean isRootClientHandler = null == request.getProperties().get("dd.span");
if (isRootClientHandler) {
@@ -91,13 +89,13 @@ public final class JaxRsClientV1Instrumentation extends Instrumenter.Default {
}
}
- @Advice.OnMethodExit
+ @Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
public static void onExit(
@Advice.Argument(value = 0) final ClientRequest request,
@Advice.Return final ClientResponse response,
- @Advice.This final ClientHandler thisObj) {
-
- System.out.println("############ ON HANDLE ENTER");
+ @Advice.This final ClientHandler thisObj,
+ @Advice.Thrown final Throwable throwable
+ ) {
Span span = (Span) request.getProperties().get("dd.span");
if (null == span) {

MODIFY
dd-java-agent/instrumentation/jax-rs-client/jax-rs-client-1/src/test/groovy/JaxRsClientV1Test.groovy
dd-java-agent/instrumentation/jax-rs-client/jax-rs-client-1/src/test/groovy/JaxRsClientV1Test.groovy
@@ -13,7 +13,6 @@ class JaxRsClientV1Test extends HttpClientTest<JaxRsClientV1Decorator> {
headers.each { resource.header(it.key, it.value) }
def body = BODY_METHODS.contains(method) ? new ClientRequestImpl(uri, method) : null
ClientResponse response = resource.method(method, ClientResponse.class, body)
- println "################## RESPOSNE #####################" + response
callback?.call()
return response.status

Enable tracing of jax-rs client in sun package