zhaodp commented on issue #5736:
URL: https://github.com/apache/skywalking/issues/5736#issuecomment-718410785


   > `httpclient` plugin doesn't collect the parameters now, if you want, 
please enhance that plugin and add a config item like 
`plugin.springmvc.collect_http_params` and `plugin.tomcat.collect_http_params` 
to make it work
     I enhanced the httpClient-4.x-plugin, it worked  :
      `    @Override
       public void beforeMethod(EnhancedInstance objInst, Method method, 
Object[] allArguments, Class<?>[] argumentsTypes,
           MethodInterceptResult result) throws Throwable {
           if (allArguments[0] == null || allArguments[1] == null) {
               // illegal args, can't trace. ignore.
               return;
           }
           final HttpHost httpHost = (HttpHost) allArguments[0];
           HttpRequest httpRequest = (HttpRequest) allArguments[1];
           final ContextCarrier contextCarrier = new ContextCarrier();
   
           String remotePeer = httpHost.getHostName() + ":" + port(httpHost);
   
           String uri = httpRequest.getRequestLine().getUri();
           String requestURI = getRequestURI(uri);
           String operationName = requestURI;
           AbstractSpan span = ContextManager.createExitSpan(operationName, 
contextCarrier, remotePeer);
   
           span.setComponent(ComponentsDefine.HTTPCLIENT);
           Tags.URL.set(span, buildSpanValue(httpHost, uri));
           Tags.HTTP.METHOD.set(span, httpRequest.getRequestLine().getMethod());
           SpanLayer.asHttp(span);
   
           **if (httpRequest  instanceof HttpEntityEnclosingRequest) {
               HttpEntityEnclosingRequest httpEntityEnclosingRequest = 
(HttpEntityEnclosingRequest) httpRequest;
               HttpEntity entity = httpEntityEnclosingRequest.getEntity();
               if (entity instanceof StringEntity) {
                   String tagValue = EntityUtils.toString(entity);
                   tagValue = StringUtil.cut(tagValue, 1024);
                   Tags.HTTP.PARAMS.set(span, tagValue);
               }
           }**
   
           CarrierItem next = contextCarrier.items();
           while (next.hasNext()) {
               next = next.next();
               httpRequest.setHeader(next.getHeadKey(), next.getHeadValue());
           }
       }`


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


Reply via email to