You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@skywalking.apache.org by wu...@apache.org on 2018/08/06 08:27:50 UTC
[incubator-skywalking] branch 6.0 updated: Fix operation name is
empty issue (#1525)
This is an automated email from the ASF dual-hosted git repository.
wusheng pushed a commit to branch 6.0
in repository https://gitbox.apache.org/repos/asf/incubator-skywalking.git
The following commit(s) were added to refs/heads/6.0 by this push:
new e8456c0 Fix operation name is empty issue (#1525)
e8456c0 is described below
commit e8456c0f83d0fb08bfb7173cc3dc8d69d799fc9f
Author: Xin,Zhang <zh...@apache.org>
AuthorDate: Mon Aug 6 16:23:38 2018 +0800
Fix operation name is empty issue (#1525)
---
.../v4/HttpClientExecuteInterceptor.java | 27 +++++++++++++++++-----
1 file changed, 21 insertions(+), 6 deletions(-)
diff --git a/apm-sniffer/apm-sdk-plugin/httpClient-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/httpClient/v4/HttpClientExecuteInterceptor.java b/apm-sniffer/apm-sdk-plugin/httpClient-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/httpClient/v4/HttpClientExecuteInterceptor.java
index 5d2cf29..af077b9 100644
--- a/apm-sniffer/apm-sdk-plugin/httpClient-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/httpClient/v4/HttpClientExecuteInterceptor.java
+++ b/apm-sniffer/apm-sdk-plugin/httpClient-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/httpClient/v4/HttpClientExecuteInterceptor.java
@@ -19,12 +19,21 @@
package org.apache.skywalking.apm.plugin.httpClient.v4;
import java.lang.reflect.Method;
+import java.net.MalformedURLException;
import java.net.URL;
-import org.apache.http.*;
-import org.apache.skywalking.apm.agent.core.context.*;
+import org.apache.http.HttpHost;
+import org.apache.http.HttpRequest;
+import org.apache.http.HttpResponse;
+import org.apache.http.StatusLine;
+import org.apache.skywalking.apm.agent.core.context.CarrierItem;
+import org.apache.skywalking.apm.agent.core.context.ContextCarrier;
+import org.apache.skywalking.apm.agent.core.context.ContextManager;
import org.apache.skywalking.apm.agent.core.context.tag.Tags;
-import org.apache.skywalking.apm.agent.core.context.trace.*;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.*;
+import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan;
+import org.apache.skywalking.apm.agent.core.context.trace.SpanLayer;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
public class HttpClientExecuteInterceptor implements InstanceMethodsAroundInterceptor {
@@ -43,7 +52,8 @@ public class HttpClientExecuteInterceptor implements InstanceMethodsAroundInterc
"https".equals(httpHost.getSchemeName().toLowerCase()) ? 443 : 80);
String uri = httpRequest.getRequestLine().getUri();
- String operationName = uri.startsWith("http") ? new URL(uri).getPath() : uri;
+ String requestURI = getRequestURI(uri);
+ String operationName = uri.startsWith("http") ? requestURI : uri;
AbstractSpan span = ContextManager.createExitSpan(operationName, contextCarrier, remotePeer);
span.setComponent(ComponentsDefine.HTTPCLIENT);
@@ -76,7 +86,7 @@ public class HttpClientExecuteInterceptor implements InstanceMethodsAroundInterc
}
}
}
-
+
ContextManager.stopSpan();
return ret;
}
@@ -87,4 +97,9 @@ public class HttpClientExecuteInterceptor implements InstanceMethodsAroundInterc
activeSpan.errorOccurred();
activeSpan.log(t);
}
+
+ private String getRequestURI(String uri) throws MalformedURLException {
+ String requestPath = new URL(uri).getPath();
+ return requestPath != null && requestPath.length() > 0 ? requestPath : "/";
+ }
}