Search in sources :

Example 61 with AbstractSpan

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

the class MotanConsumerInterceptor method beforeMethod.

@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable {
    URL url = (URL) objInst.getSkyWalkingDynamicField();
    Request request = (Request) allArguments[0];
    if (url != null) {
        ContextCarrier contextCarrier = new ContextCarrier();
        String remotePeer = url.getHost() + ":" + url.getPort();
        AbstractSpan span = ContextManager.createExitSpan(generateOperationName(url, request), contextCarrier, remotePeer);
        span.setComponent(ComponentsDefine.MOTAN);
        Tags.URL.set(span, url.getIdentity());
        SpanLayer.asRPCFramework(span);
        CarrierItem next = contextCarrier.items();
        while (next.hasNext()) {
            next = next.next();
            request.setAttachment(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(com.weibo.api.motan.rpc.Request) URL(com.weibo.api.motan.rpc.URL) AbstractSpan(org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan)

Example 62 with AbstractSpan

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

the class MotanConsumerInterceptor method afterMethod.

@Override
public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, Object ret) throws Throwable {
    Response response = (Response) ret;
    if (response != null && response.getException() != null) {
        AbstractSpan span = ContextManager.activeSpan();
        span.errorOccurred();
        span.log(response.getException());
    }
    ContextManager.stopSpan();
    return ret;
}
Also used : Response(com.weibo.api.motan.rpc.Response) AbstractSpan(org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan)

Example 63 with AbstractSpan

use of org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan 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)

Example 64 with AbstractSpan

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

the class HandleInterceptor method beforeMethod.

@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable {
    HttpChannel httpChannel = (HttpChannel) allArguments[0];
    HttpServletRequest servletRequest = httpChannel.getRequest();
    ContextCarrier contextCarrier = new ContextCarrier();
    CarrierItem next = contextCarrier.items();
    while (next.hasNext()) {
        next = next.next();
        next.setHeadValue(servletRequest.getHeader(next.getHeadKey()));
    }
    AbstractSpan span = ContextManager.createEntrySpan(servletRequest.getRequestURI(), contextCarrier);
    Tags.URL.set(span, servletRequest.getRequestURL().toString());
    Tags.HTTP.METHOD.set(span, servletRequest.getMethod());
    span.setComponent(ComponentsDefine.JETTY_SERVER);
    SpanLayer.asHttp(span);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) ContextCarrier(org.apache.skywalking.apm.agent.core.context.ContextCarrier) CarrierItem(org.apache.skywalking.apm.agent.core.context.CarrierItem) HttpChannel(org.eclipse.jetty.server.HttpChannel) AbstractSpan(org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan)

Example 65 with AbstractSpan

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

the class HandleInterceptor method afterMethod.

@Override
public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, Object ret) throws Throwable {
    HttpChannel httpChannel = (HttpChannel) allArguments[0];
    HttpServletResponse servletResponse = httpChannel.getResponse();
    AbstractSpan span = ContextManager.activeSpan();
    if (servletResponse.getStatus() >= 400) {
        span.errorOccurred();
        Tags.STATUS_CODE.set(span, Integer.toString(servletResponse.getStatus()));
    }
    ContextManager.stopSpan();
    return ret;
}
Also used : HttpChannel(org.eclipse.jetty.server.HttpChannel) HttpServletResponse(javax.servlet.http.HttpServletResponse) AbstractSpan(org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan)

Aggregations

AbstractSpan (org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan)141 ContextCarrier (org.apache.skywalking.apm.agent.core.context.ContextCarrier)36 CarrierItem (org.apache.skywalking.apm.agent.core.context.CarrierItem)29 URI (java.net.URI)7 AbstractTracingSpan (org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan)7 TraceSegment (org.apache.skywalking.apm.agent.core.context.trace.TraceSegment)7 ConnectionInfo (org.apache.skywalking.apm.plugin.jdbc.trace.ConnectionInfo)7 HttpServletResponse (javax.servlet.http.HttpServletResponse)6 StatementEnhanceInfos (org.apache.skywalking.apm.plugin.jdbc.define.StatementEnhanceInfos)6 Invocation (io.servicecomb.core.Invocation)5 HttpServletRequest (javax.servlet.http.HttpServletRequest)5 Invocation (org.apache.servicecomb.core.Invocation)5 SQLException (java.sql.SQLException)4 Metadata (io.grpc.Metadata)3 Field (java.lang.reflect.Field)3 List (java.util.List)3 TraceSegmentRef (org.apache.skywalking.apm.agent.core.context.trace.TraceSegmentRef)3 EnhancedInstance (org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance)3 Request (com.weibo.api.motan.rpc.Request)2 Response (com.weibo.api.motan.rpc.Response)2