Search in sources :

Example 26 with CarrierItem

use of org.apache.skywalking.apm.agent.core.context.CarrierItem in project incubator-skywalking by apache.

the class ResinV3Interceptor method beforeMethod.

@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable {
    CauchoRequest request = (CauchoRequest) allArguments[0];
    ContextCarrier contextCarrier = new ContextCarrier();
    CarrierItem next = contextCarrier.items();
    while (next.hasNext()) {
        next = next.next();
        next.setHeadValue(request.getHeader(next.getHeadKey()));
    }
    AbstractSpan span = ContextManager.createEntrySpan(request.getPageURI(), contextCarrier);
    span.setComponent(ComponentsDefine.RESIN);
    Tags.URL.set(span, appendRequestURL(request));
    SpanLayer.asHttp(span);
}
Also used : CauchoRequest(com.caucho.server.connection.CauchoRequest) ContextCarrier(org.apache.skywalking.apm.agent.core.context.ContextCarrier) CarrierItem(org.apache.skywalking.apm.agent.core.context.CarrierItem) AbstractSpan(org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan)

Example 27 with CarrierItem

use of org.apache.skywalking.apm.agent.core.context.CarrierItem in project incubator-skywalking by apache.

the class AbstractMessageConsumeInterceptor method getContextCarrierFromMessage.

private ContextCarrier getContextCarrierFromMessage(MessageExt message) {
    ContextCarrier contextCarrier = new ContextCarrier();
    CarrierItem next = contextCarrier.items();
    while (next.hasNext()) {
        next = next.next();
        next.setHeadValue(message.getUserProperty(next.getHeadKey()));
    }
    return contextCarrier;
}
Also used : ContextCarrier(org.apache.skywalking.apm.agent.core.context.ContextCarrier) CarrierItem(org.apache.skywalking.apm.agent.core.context.CarrierItem)

Example 28 with CarrierItem

use of org.apache.skywalking.apm.agent.core.context.CarrierItem in project incubator-skywalking by apache.

the class ActionMethodInterceptor method beforeMethod.

@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable {
    PathMappingCache pathMappingCache = (PathMappingCache) objInst.getSkyWalkingDynamicField();
    String requestURL = pathMappingCache.findPathMapping(method);
    if (requestURL == null) {
        At methodRequestMapping = method.getAnnotation(At.class);
        if (methodRequestMapping.value().length > 0) {
            requestURL = methodRequestMapping.value()[0];
        } else {
            requestURL = "";
        }
        pathMappingCache.addPathMapping(method, requestURL);
        requestURL = pathMappingCache.findPathMapping(method);
    }
    HttpServletRequest request = Mvcs.getReq();
    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.NUTZ_MVC_ANNOTATION);
    SpanLayer.asHttp(span);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) ContextCarrier(org.apache.skywalking.apm.agent.core.context.ContextCarrier) At(org.nutz.mvc.annotation.At) CarrierItem(org.apache.skywalking.apm.agent.core.context.CarrierItem) AbstractSpan(org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan)

Example 29 with CarrierItem

use of org.apache.skywalking.apm.agent.core.context.CarrierItem in project incubator-skywalking by apache.

the class ResinV4Interceptor method beforeMethod.

@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable {
    CauchoRequest request = (CauchoRequest) allArguments[0];
    ContextCarrier contextCarrier = new ContextCarrier();
    CarrierItem next = contextCarrier.items();
    while (next.hasNext()) {
        next = next.next();
        next.setHeadValue(request.getHeader(next.getHeadKey()));
    }
    AbstractSpan span = ContextManager.createEntrySpan(request.getPageURI(), contextCarrier);
    span.setComponent(ComponentsDefine.RESIN);
    Tags.URL.set(span, appendRequestURL(request));
    SpanLayer.asHttp(span);
}
Also used : CauchoRequest(com.caucho.server.http.CauchoRequest) ContextCarrier(org.apache.skywalking.apm.agent.core.context.ContextCarrier) CarrierItem(org.apache.skywalking.apm.agent.core.context.CarrierItem) AbstractSpan(org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan)

Example 30 with CarrierItem

use of org.apache.skywalking.apm.agent.core.context.CarrierItem in project incubator-skywalking by apache.

the class SyncHttpRequestSendInterceptor method beforeMethod.

@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable {
    HttpRequest request = (HttpRequest) objInst;
    ContextCarrier contextCarrier = new ContextCarrier();
    AbstractSpan span = ContextManager.createExitSpan(request.getURI().getPath(), contextCarrier, request.getHost() + ":" + request.getPort());
    span.setComponent(ComponentsDefine.JETTY_CLIENT);
    Tags.HTTP.METHOD.set(span, getHttpMethod(request));
    Tags.URL.set(span, request.getURI().toString());
    SpanLayer.asHttp(span);
    CarrierItem next = contextCarrier.items();
    HttpFields field = request.getHeaders();
    while (next.hasNext()) {
        next = next.next();
        field.add(next.getHeadKey(), next.getHeadValue());
    }
}
Also used : HttpRequest(org.eclipse.jetty.client.HttpRequest) ContextCarrier(org.apache.skywalking.apm.agent.core.context.ContextCarrier) CarrierItem(org.apache.skywalking.apm.agent.core.context.CarrierItem) HttpFields(org.eclipse.jetty.http.HttpFields) AbstractSpan(org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan)

Aggregations

CarrierItem (org.apache.skywalking.apm.agent.core.context.CarrierItem)35 ContextCarrier (org.apache.skywalking.apm.agent.core.context.ContextCarrier)35 AbstractSpan (org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan)29 HttpServletRequest (javax.servlet.http.HttpServletRequest)5 Metadata (io.grpc.Metadata)3 Field (java.lang.reflect.Field)3 URI (java.net.URI)3 URL (java.net.URL)3 EnhancedInstance (org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance)3 Request (com.weibo.api.motan.rpc.Request)2 ForwardingClientCallListener (io.grpc.ForwardingClientCallListener)2 Format (io.opentracing.propagation.Format)2 TextMap (io.opentracing.propagation.TextMap)2 Invocation (io.servicecomb.core.Invocation)2 MalformedURLException (java.net.MalformedURLException)2 Map (java.util.Map)2 Headers (okhttp3.Headers)2 HttpUrl (okhttp3.HttpUrl)2 Request (okhttp3.Request)2 Invocation (org.apache.servicecomb.core.Invocation)2