Convert the Redisson lock span into an async span (#667)
This commit is contained in:
parent
bbb177a893
commit
eebc4512ec
|
|
@ -10,8 +10,9 @@ Release Notes.
|
||||||
* Support for tracing spring-cloud-gateway 4.x in gateway-4.x-plugin.
|
* Support for tracing spring-cloud-gateway 4.x in gateway-4.x-plugin.
|
||||||
* Fix re-transform bug when plugin enhanced class proxy parent method.
|
* Fix re-transform bug when plugin enhanced class proxy parent method.
|
||||||
* Fix error HTTP status codes not recording as SLA failures in Vert.x plugins.
|
* Fix error HTTP status codes not recording as SLA failures in Vert.x plugins.
|
||||||
* Support for HttpExchange request tracing
|
* Support for HttpExchange request tracing.
|
||||||
* Support tracing for async producing, batch sync consuming, and batch async consuming in rocketMQ-client-java-5.x-plugin.
|
* Support tracing for async producing, batch sync consuming, and batch async consuming in rocketMQ-client-java-5.x-plugin.
|
||||||
|
* Convert the Redisson span into an async span.
|
||||||
|
|
||||||
#### Documentation
|
#### Documentation
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,9 +26,11 @@ import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedI
|
||||||
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
|
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
|
||||||
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
|
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
|
||||||
import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
|
import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
|
||||||
|
import org.redisson.api.RFuture;
|
||||||
import org.redisson.api.RLock;
|
import org.redisson.api.RLock;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
public class RedissonHighLevelLockInterceptor implements InstanceMethodsAroundInterceptor {
|
public class RedissonHighLevelLockInterceptor implements InstanceMethodsAroundInterceptor {
|
||||||
|
|
@ -48,7 +50,19 @@ public class RedissonHighLevelLockInterceptor implements InstanceMethodsAroundIn
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, Object ret) throws Throwable {
|
public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, Object ret) throws Throwable {
|
||||||
|
AbstractSpan span = ContextManager.activeSpan();
|
||||||
|
span.prepareForAsync();
|
||||||
ContextManager.stopSpan();
|
ContextManager.stopSpan();
|
||||||
|
|
||||||
|
RFuture<Object> future = (RFuture) ret;
|
||||||
|
CompletableFuture<Object> completableFuture = future.toCompletableFuture();
|
||||||
|
completableFuture.whenComplete((res, ex) -> {
|
||||||
|
if (ex != null) {
|
||||||
|
span.errorOccurred();
|
||||||
|
span.log(ex);
|
||||||
|
}
|
||||||
|
span.asyncFinish();
|
||||||
|
});
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,9 +26,11 @@ import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedI
|
||||||
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
|
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
|
||||||
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
|
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
|
||||||
import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
|
import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
|
||||||
|
import org.redisson.api.RFuture;
|
||||||
import org.redisson.api.RLock;
|
import org.redisson.api.RLock;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
public class RedissonLockInterceptor implements InstanceMethodsAroundInterceptor {
|
public class RedissonLockInterceptor implements InstanceMethodsAroundInterceptor {
|
||||||
|
|
@ -48,7 +50,19 @@ public class RedissonLockInterceptor implements InstanceMethodsAroundInterceptor
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, Object ret) throws Throwable {
|
public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, Object ret) throws Throwable {
|
||||||
|
AbstractSpan span = ContextManager.activeSpan();
|
||||||
|
span.prepareForAsync();
|
||||||
ContextManager.stopSpan();
|
ContextManager.stopSpan();
|
||||||
|
|
||||||
|
RFuture<Object> future = (RFuture) ret;
|
||||||
|
CompletableFuture<Object> completableFuture = future.toCompletableFuture();
|
||||||
|
completableFuture.whenComplete((res, ex) -> {
|
||||||
|
if (ex != null) {
|
||||||
|
span.errorOccurred();
|
||||||
|
span.log(ex);
|
||||||
|
}
|
||||||
|
span.asyncFinish();
|
||||||
|
});
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue