Search in sources :

Example 46 with AbstractSpan

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

the class RealCallInterceptor method afterMethod.

/**
 * Get the status code from {@link Response}, when status code greater than 400, it means there was some errors in
 * the server.
 * Finish the {@link AbstractSpan}.
 *
 * @param method
 * @param ret the method's original return value.
 * @return
 * @throws Throwable
 */
@Override
public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, Object ret) throws Throwable {
    Response response = (Response) ret;
    int statusCode = response.code();
    AbstractSpan span = ContextManager.activeSpan();
    if (statusCode >= 400) {
        span.errorOccurred();
        Tags.STATUS_CODE.set(span, Integer.toString(statusCode));
    }
    ContextManager.stopSpan();
    return ret;
}
Also used : Response(okhttp3.Response) AbstractSpan(org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan)

Example 47 with AbstractSpan

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

the class RealCallInterceptor method handleMethodException.

@Override
public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, Throwable t) {
    AbstractSpan abstractSpan = ContextManager.activeSpan();
    abstractSpan.errorOccurred();
    abstractSpan.log(t);
}
Also used : AbstractSpan(org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan)

Example 48 with AbstractSpan

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

the class ResinV3Interceptor method afterMethod.

@Override
public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, Object ret) throws Throwable {
    HttpResponse response = (HttpResponse) allArguments[1];
    AbstractSpan span = ContextManager.activeSpan();
    if (response.getStatusCode() >= 400) {
        Tags.STATUS_CODE.set(span, Integer.toString(response.getStatusCode()));
        span.errorOccurred();
    }
    ContextManager.stopSpan();
    return ret;
}
Also used : HttpResponse(com.caucho.server.http.HttpResponse) AbstractSpan(org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan)

Example 49 with AbstractSpan

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

the class ResinV3Interceptor method handleMethodException.

@Override
public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, Throwable t) {
    AbstractSpan activeSpan = ContextManager.activeSpan();
    activeSpan.log(t);
    activeSpan.errorOccurred();
}
Also used : AbstractSpan(org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan)

Example 50 with AbstractSpan

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

the class AbstractMessageConsumeInterceptor method beforeMethod.

@Override
public final void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable {
    List<MessageExt> msgs = (List<MessageExt>) allArguments[0];
    ContextCarrier contextCarrier = getContextCarrierFromMessage(msgs.get(0));
    AbstractSpan span = ContextManager.createEntrySpan(CONSUMER_OPERATION_NAME_PREFIX + msgs.get(0).getTopic() + "/Consumer", contextCarrier);
    span.setComponent(ComponentsDefine.ROCKET_MQ);
    span.setLayer(SpanLayer.MQ);
    for (int i = 1; i < msgs.size(); i++) {
        ContextManager.extract(getContextCarrierFromMessage(msgs.get(i)));
    }
}
Also used : MessageExt(com.alibaba.rocketmq.common.message.MessageExt) ContextCarrier(org.apache.skywalking.apm.agent.core.context.ContextCarrier) List(java.util.List) 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