Search in sources :

Example 11 with EnhancedInstance

use of org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance in project incubator-skywalking by apache.

the class EnqueueInterceptor method beforeMethod.

@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable {
    EnhancedInstance callbackInstance = (EnhancedInstance) allArguments[0];
    Request request = (Request) objInst.getSkyWalkingDynamicField();
    ContextManager.createLocalSpan("Async" + request.url().uri().getPath());
    /**
     * Here is the process about how to trace the async function.
     *
     * 1. Storage `Request` object into `RealCall` instance when the constructor of `RealCall` called.
     * 2. Put the `RealCall` instance to `CallBack` instance
     * 3. Get the `RealCall` instance from `CallBack` and then Put the `RealCall` into `AsyncCall` instance
     *    since the constructor of `RealCall` called.
     * 5. Create the exit span by using the `RealCall` instance when `AsyncCall` method called.
     */
    callbackInstance.setSkyWalkingDynamicField(new EnhanceRequiredInfo(objInst, ContextManager.capture()));
}
Also used : EnhancedInstance(org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance) Request(okhttp3.Request)

Example 12 with EnhancedInstance

use of org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance in project incubator-skywalking by apache.

the class SWExecutionHookWrapper method onStart.

@Override
public <T> void onStart(HystrixInvokable<T> commandInstance) {
    EnhancedInstance enhancedInstance = (EnhancedInstance) commandInstance;
    EnhanceRequireObjectCache enhanceRequireObjectCache = (EnhanceRequireObjectCache) enhancedInstance.getSkyWalkingDynamicField();
    enhanceRequireObjectCache.setContextSnapshot(ContextManager.capture());
    actual.onStart(commandInstance);
}
Also used : EnhancedInstance(org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance)

Aggregations

EnhancedInstance (org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance)12 AbstractSpan (org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan)4 CarrierItem (org.apache.skywalking.apm.agent.core.context.CarrierItem)3 ContextCarrier (org.apache.skywalking.apm.agent.core.context.ContextCarrier)3 Before (org.junit.Before)2 Message (com.alibaba.rocketmq.common.message.Message)1 SendMessageRequestHeader (com.alibaba.rocketmq.common.protocol.header.SendMessageRequestHeader)1 InetSocketAddress (java.net.InetSocketAddress)1 Request (okhttp3.Request)1 SessionRequest (org.apache.http.nio.reactor.SessionRequest)1 ProducerRecord (org.apache.kafka.clients.producer.ProducerRecord)1 Message (org.apache.rocketmq.common.message.Message)1 SendMessageRequestHeader (org.apache.rocketmq.common.protocol.header.SendMessageRequestHeader)1 SendCallBackEnhanceInfo (org.apache.skywalking.apm.plugin.rocketMQ.v3.define.SendCallBackEnhanceInfo)1 SendCallBackEnhanceInfo (org.apache.skywalking.apm.plugin.rocketMQ.v4.define.SendCallBackEnhanceInfo)1