Skip to content

Commit a976175

Browse files
committed
Fix
1 parent 8387a6c commit a976175

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

apm-sniffer/bootstrap-plugins/jdk-httpclient-plugin/src/main/java/org/apache/skywalking/apm/plugin/HttpClientSendAsyncInterceptor.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
import java.net.URI;
3333
import java.net.http.HttpRequest;
3434
import java.net.http.HttpResponse;
35+
import java.util.HashMap;
36+
import java.util.Map;
3537
import java.util.concurrent.CompletableFuture;
3638

3739
public class HttpClientSendAsyncInterceptor implements InstanceMethodsAroundInterceptor {
@@ -66,10 +68,11 @@ public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allA
6668
ret = future.whenComplete((response, throwable) -> {
6769
try {
6870
if (throwable != null) {
69-
Tags.HTTP_RESPONSE_STATUS_CODE.set(span, 500);
7071
span.errorOccurred();
7172
span.log(throwable);
72-
} else if (response instanceof HttpResponse) {
73+
return;
74+
}
75+
if (response instanceof HttpResponse) {
7376
HttpResponse<?> httpResponse = (HttpResponse<?>) response;
7477
int statusCode = httpResponse.statusCode();
7578
Tags.HTTP_RESPONSE_STATUS_CODE.set(span, statusCode);
@@ -82,7 +85,9 @@ public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allA
8285
}
8386
});
8487
} else {
85-
Tags.HTTP_RESPONSE_STATUS_CODE.set(span, 404);
88+
Map<String, String> eventMap = new HashMap<String, String>();
89+
eventMap.put("error", "No response");
90+
span.log(System.currentTimeMillis(), eventMap);
8691
span.errorOccurred();
8792
}
8893
ContextManager.stopSpan();

0 commit comments

Comments
 (0)