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 2021/11/19 02:42:09 UTC

[GitHub] [skywalking] durongpeng opened a new issue #8148: [Bug] A question called "sw8-correlation" Header is null

durongpeng opened a new issue #8148:
URL: https://github.com/apache/skywalking/issues/8148


   ### Search before asking
   
   - [X] I had searched in the [issues](https://github.com/apache/skywalking/issues?q=is%3Aissue) and found no similar issues.
   
   
   ### Apache SkyWalking Component
   
   Java Agent (apache/skywalking-java)
   
   ### What happened
   
   The version I'm using is 8.4.0.
   When I call the third-party service with resttemplate after I mount the Javaagent,  it returns HTTP 400.
   It is normal for me to use postman to call this interface.
   After I debugged the code, I found that there were more headers on the Request after skywalking was mounted,such as "sw8"、"sw8-correlation"、"sw8-x".
   The problem is that the header of "sw8-correlation" is an empty string. 
   Some versions of springboot applications will return bad request. 
   I tried to add content to "sw8-correlation", but failed.
   Finally, I can only add code in the "aftermethod" of org.apache.skywalking.apm.plugin.spring.resttemplate.sync.Restrequestinterceptor.class.
   
   ### What you expected to happen
   
   Remove “ sw8-correlation” or add content to it.
   It would be better if I could understand the design principle of “ sw8-correlation”, I guess it is related to static method calls and I don't know if it is correct.
   
   ### How to reproduce
   
   Finally, I can only add code in the "aftermethod" of org.apache.skywalking.apm.plugin.spring.resttemplate.sync.Restrequestinterceptor.class.
   `
       public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
           Object ret) throws Throwable {
           ClientHttpRequest clientHttpRequest = (ClientHttpRequest) ret;
           if (clientHttpRequest instanceof AbstractClientHttpRequest) {
               AbstractClientHttpRequest httpRequest = (AbstractClientHttpRequest) clientHttpRequest;
               ContextCarrier contextCarrier = RestTemplateRuntimeContextHelper.getContextCarrier();
               CarrierItem next = contextCarrier.items();
               while (next.hasNext()) {
                   next = next.next();
                   **if (StringUtil.isNotEmpty(next.getHeadValue())) {**
                       httpRequest.getHeaders().set(next.getHeadKey(), next.getHeadValue());
                   **}**
               }
           }
           return ret;
       }`
   
   ### Anything else
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
   


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking] wu-sheng closed issue #8148: [Bug] A question called "sw8-correlation" Header is null

Posted by GitBox <gi...@apache.org>.
wu-sheng closed issue #8148:
URL: https://github.com/apache/skywalking/issues/8148


   


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org