wu-sheng commented on a change in pull request #3854: Intercept feign URL 
without parameters
URL: https://github.com/apache/skywalking/pull/3854#discussion_r346810577
 
 

 ##########
 File path: 
apm-sniffer/apm-sdk-plugin/feign-default-http-9.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/feign/http/v9/DefaultHttpClientInterceptor.java
 ##########
 @@ -48,26 +50,31 @@
  */
 public class DefaultHttpClientInterceptor implements 
InstanceMethodsAroundInterceptor {
 
-    private static final String COMPONENT_NAME = "FeignDefaultHttp";
-
     /**
      * Get the {@link feign.Request} from {@link EnhancedInstance}, then 
create {@link AbstractSpan} and set host, port,
      * kind, component, url from {@link feign.Request}. Through the reflection 
of the way, set the http header of
      * context data into {@link feign.Request#headers}.
      *
-     * @param method
+     * @param method intercept method
      * @param result change this result, if you want to truncate the method.
-     * @throws Throwable
+     * @throws Throwable NoSuchFieldException or IllegalArgumentException
      */
-    @Override public void beforeMethod(EnhancedInstance objInst, Method 
method, Object[] allArguments,
-        Class<?>[] argumentsTypes, MethodInterceptResult result) throws 
Throwable {
-        Request request = (Request)allArguments[0];
-
+    @Override
+    public void beforeMethod(EnhancedInstance objInst, Method method, Object[] 
allArguments,
+                             Class<?>[] argumentsTypes, MethodInterceptResult 
result) throws Throwable {
+        Request request = (Request) allArguments[0];
+        String originUrl = PathVarInterceptor.ORIGIN_URL_CONTEXT.get();
+        String resolvedUrl = PathVarInterceptor.RESOLVED_URL_CONTEXT.get();
         URL url = new URL(request.url());
         ContextCarrier contextCarrier = new ContextCarrier();
         int port = url.getPort() == -1 ? 80 : url.getPort();
         String remotePeer = url.getHost() + ":" + port;
         String operationName = url.getPath();
+        if (!StringUtil.isEmpty(originUrl) && 
!StringUtil.isEmpty(resolvedUrl)) {
+            operationName = operationName.replace(resolvedUrl,originUrl);
+        }
+        PathVarInterceptor.ORIGIN_URL_CONTEXT.remove();
+        PathVarInterceptor.RESOLVED_URL_CONTEXT.remove();
 
 Review comment:
   This remove should be in `try/final`, otherwise, maybe leak if above codes 
have an exception.

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


With regards,
Apache Git Services

Reply via email to