Search in sources :

Example 56 with AbstractSpan

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

the class MongoDBMethodInterceptor method beforeMethod.

@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable {
    Object[] arguments = allArguments;
    String executeMethod = arguments[0].getClass().getSimpleName();
    String remotePeer = (String) objInst.getSkyWalkingDynamicField();
    AbstractSpan span = ContextManager.createExitSpan(MONGO_DB_OP_PREFIX + executeMethod, new ContextCarrier(), remotePeer);
    span.setComponent(ComponentsDefine.MONGODB);
    Tags.DB_TYPE.set(span, DB_TYPE);
    SpanLayer.asDB(span);
    if (Config.Plugin.MongoDB.TRACE_PARAM) {
        Tags.DB_STATEMENT.set(span, executeMethod + " " + this.getTraceParam(arguments[0]));
    }
}
Also used : ContextCarrier(org.apache.skywalking.apm.agent.core.context.ContextCarrier) AbstractSpan(org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan)

Example 57 with AbstractSpan

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

the class MotanProviderInterceptor 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.log(response.getException());
        span.errorOccurred();
    }
    ContextManager.stopSpan();
    return ret;
}
Also used : Response(com.weibo.api.motan.rpc.Response) AbstractSpan(org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan)

Example 58 with AbstractSpan

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

the class MotanProviderInterceptor method beforeMethod.

@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable {
    Request request = (Request) allArguments[0];
    ContextCarrier contextCarrier = new ContextCarrier();
    CarrierItem next = contextCarrier.items();
    while (next.hasNext()) {
        next = next.next();
        next.setHeadValue(request.getAttachments().get(next.getHeadKey()));
    }
    AbstractSpan span = ContextManager.createEntrySpan(generateViewPoint(request), contextCarrier);
    SpanLayer.asRPCFramework(span);
    span.setComponent(ComponentsDefine.MOTAN);
}
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) AbstractSpan(org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan)

Example 59 with AbstractSpan

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

the class PreparedStatementExecuteMethodsInterceptor method beforeMethod.

@Override
public final void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable {
    StatementEnhanceInfos cacheObject = (StatementEnhanceInfos) objInst.getSkyWalkingDynamicField();
    ConnectionInfo connectInfo = cacheObject.getConnectionInfo();
    /**
     * For avoid NPE. In this particular case, Execute sql inside the {@link com.mysql.jdbc.ConnectionImpl} constructor,
     * before the interceptor sets the connectionInfo.
     *
     * @see JDBCDriverInterceptor#afterMethod(EnhancedInstance, Method, Object[], Class[], Object)
     */
    if (connectInfo != null) {
        AbstractSpan span = ContextManager.createExitSpan(buildOperationName(connectInfo, method.getName(), cacheObject.getStatementName()), connectInfo.getDatabasePeer());
        Tags.DB_TYPE.set(span, "sql");
        Tags.DB_INSTANCE.set(span, connectInfo.getDatabaseName());
        Tags.DB_STATEMENT.set(span, cacheObject.getSql());
        span.setComponent(connectInfo.getComponent());
        SpanLayer.asDB(span);
    }
}
Also used : ConnectionInfo(org.apache.skywalking.apm.plugin.jdbc.trace.ConnectionInfo) StatementEnhanceInfos(org.apache.skywalking.apm.plugin.jdbc.define.StatementEnhanceInfos) AbstractSpan(org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan)

Example 60 with AbstractSpan

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

the class MotanConsumerInterceptor method handleMethodException.

@Override
public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, Throwable t) {
    AbstractSpan span = ContextManager.activeSpan();
    span.errorOccurred();
    span.log(t);
}
Also used : 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