Search in sources :

Example 1 with METHOD

use of org.nutz.http.Request.METHOD in project incubator-skywalking by apache.

the class SenderSendInterceptor method beforeMethod.

@Override
public void beforeMethod(final EnhancedInstance objInst, final Method method, final Object[] allArguments, final Class<?>[] argumentsTypes, final MethodInterceptResult result) throws Throwable {
    Request req = (Request) objInst.getSkyWalkingDynamicField();
    final URI requestURL = req.getUrl().toURI();
    final METHOD httpMethod = req.getMethod();
    final ContextCarrier contextCarrier = new ContextCarrier();
    String remotePeer = requestURL.getHost() + ":" + requestURL.getPort();
    AbstractSpan span = ContextManager.createExitSpan(requestURL.getPath(), contextCarrier, remotePeer);
    span.setComponent(ComponentsDefine.NUTZ_HTTP);
    Tags.URL.set(span, requestURL.getScheme() + "://" + requestURL.getHost() + ":" + requestURL.getPort() + requestURL.getPath());
    Tags.HTTP.METHOD.set(span, httpMethod.toString());
    SpanLayer.asHttp(span);
    CarrierItem next = contextCarrier.items();
    while (next.hasNext()) {
        next = next.next();
        req.getHeader().set(next.getHeadKey(), next.getHeadValue());
    }
}
Also used : ContextCarrier(org.apache.skywalking.apm.agent.core.context.ContextCarrier) CarrierItem(org.apache.skywalking.apm.agent.core.context.CarrierItem) Request(org.nutz.http.Request) METHOD(org.nutz.http.Request.METHOD) URI(java.net.URI) AbstractSpan(org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan)

Aggregations

URI (java.net.URI)1 CarrierItem (org.apache.skywalking.apm.agent.core.context.CarrierItem)1 ContextCarrier (org.apache.skywalking.apm.agent.core.context.ContextCarrier)1 AbstractSpan (org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan)1 Request (org.nutz.http.Request)1 METHOD (org.nutz.http.Request.METHOD)1