candyleer commented on issue #1325: Fix #1280: Modify tomcat interceptor
URL: 
https://github.com/apache/incubator-skywalking/pull/1325#issuecomment-395659003
 
 
   in the class 
`org.apache.skywalking.apm.plugin.spring.mvc.commons.interceptor.AbstractMethodInterceptor`
   * if more than one entry span are created,entry span will merge
   * so in `beforeMethod`,the forward error request will override the request 
which user request.
   so
   ```
    @Override
       public void beforeMethod(EnhancedInstance objInst, Method method, 
Object[] allArguments, Class<?>[] argumentsTypes,
           MethodInterceptResult result) throws Throwable {
       
           EnhanceRequireObjectCache pathMappingCache = 
(EnhanceRequireObjectCache)objInst.getSkyWalkingDynamicField();
           String requestURL = pathMappingCache.findPathMapping(method);
           if (requestURL == null) {
               requestURL = getRequestURL(method);
               pathMappingCache.addPathMapping(method, requestURL);
               requestURL = pathMappingCache.findPathMapping(method);
           }
   
           String hystrixIsolateStrategy = 
(String)ContextManager.getRuntimeContext().get(ISOLATE_STRATEGY_KEY_IN_RUNNING_CONTEXT);
           HttpServletRequest request = 
(HttpServletRequest)ContextManager.getRuntimeContext().get(REQUEST_KEY_IN_RUNTIME_CONTEXT);
   
           if (hystrixIsolateStrategy != null) {
               ContextManager.createLocalSpan(requestURL);
           } else if (request != null) {
               ContextCarrier contextCarrier = new ContextCarrier();
               CarrierItem next = contextCarrier.items();
               while (next.hasNext()) {
                   next = next.next();
                   next.setHeadValue(request.getHeader(next.getHeadKey()));
               }
   
               AbstractSpan span = ContextManager.createEntrySpan(requestURL, 
contextCarrier);
               Tags.URL.set(span, request.getRequestURL().toString());
               Tags.HTTP.METHOD.set(span, request.getMethod());
               span.setComponent(ComponentsDefine.SPRING_MVC_ANNOTATION);
               SpanLayer.asHttp(span);
           }
       }
   ```
   the code in this forward error situation will create two entry span and  
they are in the same thread,so  span and tag info will be overide

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to