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/05/14 00:28:16 UTC

[incubator-skywalking] branch master updated: fix http_client plugin (#1218)

This is an automated email from the ASF dual-hosted git repository.

wusheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-skywalking.git


The following commit(s) were added to refs/heads/master by this push:
     new 1bbd5e1  fix http_client plugin (#1218)
1bbd5e1 is described below

commit 1bbd5e1c28afed0784834978cdba33d074a536a1
Author: lican <li...@foxmail.com>
AuthorDate: Mon May 14 08:28:12 2018 +0800

    fix http_client plugin (#1218)
---
 .../httpClient/v4/HttpClientExecuteInterceptor.java    | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 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 9469385..3688e39 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
@@ -18,9 +18,6 @@
 
 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.HttpHost;
 import org.apache.http.HttpRequest;
 import org.apache.http.HttpResponse;
@@ -36,6 +33,9 @@ import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceM
 import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
 import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
 
+import java.lang.reflect.Method;
+import java.net.URL;
+
 public class HttpClientExecuteInterceptor implements InstanceMethodsAroundInterceptor {
 
     @Override public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments,
@@ -47,20 +47,16 @@ public class HttpClientExecuteInterceptor implements InstanceMethodsAroundInterc
         final HttpHost httpHost = (HttpHost)allArguments[0];
         HttpRequest httpRequest = (HttpRequest)allArguments[1];
         final ContextCarrier contextCarrier = new ContextCarrier();
-        AbstractSpan span = null;
 
         String remotePeer = httpHost.getHostName() + ":" + (httpHost.getPort() > 0 ? httpHost.getPort() :
             "https".equals(httpHost.getSchemeName().toLowerCase()) ? 443 : 80);
 
-        try {
-            URL url = new URL(httpRequest.getRequestLine().getUri());
-            span = ContextManager.createExitSpan(url.getPath(), contextCarrier, remotePeer);
-        } catch (MalformedURLException e) {
-            throw e;
-        }
+        String uri = httpRequest.getRequestLine().getUri();
+        String operationName = uri.startsWith("http") ? new URL(uri).getPath() : uri;
+        AbstractSpan span = ContextManager.createExitSpan(operationName, contextCarrier, remotePeer);
 
         span.setComponent(ComponentsDefine.HTTPCLIENT);
-        Tags.URL.set(span, httpRequest.getRequestLine().getUri());
+        Tags.URL.set(span, uri);
         Tags.HTTP.METHOD.set(span, httpRequest.getRequestLine().getMethod());
         SpanLayer.asHttp(span);
 

-- 
To stop receiving notification emails like this one, please contact
wusheng@apache.org.