You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by GitBox <gi...@apache.org> on 2018/08/06 08:23:40 UTC

[GitHub] wu-sheng closed pull request #1525: Fix HTTP client v4 operation name is empty issue

wu-sheng closed pull request #1525: Fix HTTP client v4 operation name is empty issue
URL: https://github.com/apache/incubator-skywalking/pull/1525
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

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 5d2cf2908..af077b9dc 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 @@
             "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 @@
                 }
             }
         }
-        
+
         ContextManager.stopSpan();
         return ret;
     }
@@ -87,4 +97,9 @@
         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 : "/";
+    }
 }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services