dd-trace-java icon indicating copy to clipboard operation
dd-trace-java copied to clipboard

Datadog Trace Span Issue with Apache HttpClient5

Open abagavat opened this issue 1 year ago • 1 comments

We observed an issue with the Datadog trace span for outbound http requests using Apache HttpClient5. This span is missing some of the url details info, mainly the host information. Upon closer inspection we were able to identify the specific aspect advice that was applied for this interaction.

https://github.com/DataDog/dd-trace-java/blob/1496a6cfd7573667973e3722626f79d9a098714a/dd-java-agent/instrumentation/apache-httpclient-5/src/main/java/datadog/trace/instrumentation/apachehttpclient5/ApacheHttpClientInstrumentation.java#L87

In our specific case, the first parameter (host) in the method call is null. As per Apache HttpClient5 documentation this argument is allowed to be null. When it's null the implementation should derive the host information from the request itself.

https://hc.apache.org/httpcomponents-client-5.2.x/current/httpclient5/apidocs/org/apache/hc/client5/http/classic/HttpClient.html#executeOpen-org.apache.hc.core5.http.HttpHost-org.apache.hc.core5.http.ClassicHttpRequest-org.apache.hc.core5.http.protocol.HttpContext-

More specifically the below wrapper class which wraps HttpClient's BasicClassicHttpRequest should handle a null host value. The fix can either be in the constructor or by overriding the getUri method and fetch the uri from the actual request.

The impact of this issue (missing host info) is that, some of the widgets in the APM dashboard such as the dependency map are not showing the correct data.

abagavat avatar Jul 03 '24 20:07 abagavat