未验证 提交 cd029df3 编写于 作者: L Lu Jiajing 提交者: GitHub

Chore: polish methods naming for Spring Kafka (#7320)

上级 a6afcac8
......@@ -32,6 +32,7 @@ Release Notes.
* Support `guava-cache` plugin.
* Enhance the compatibility of `mysql-8.x-plugin` plugin.
* Support Kafka SASL login module.
* Chore: polish methods naming for `Spring-Kafka` plugins.
#### OAP-Backend
......
......@@ -22,11 +22,11 @@ import org.apache.skywalking.apm.agent.core.context.ContextManager;
public class InterceptorMethod {
public static void beforeMethod(String operationName) {
public static void beginKafkaPollAndInvokeIteration(String operationName) {
ContextManager.getRuntimeContext().put(Constants.KAFKA_FLAG, new KafkaContext(operationName));
}
public static Object afterMethod(Object ret) {
public static Object endKafkaPollAndInvokeIteration(Object ret) {
KafkaContext context = (KafkaContext) ContextManager.getRuntimeContext().get(Constants.KAFKA_FLAG);
if (context == null) {
return ret;
......
......@@ -33,7 +33,7 @@ public class PostRunMethodInterceptor implements InstanceMethodsAroundIntercepto
@Override
public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, Object ret) throws Throwable {
return InterceptorMethod.afterMethod(ret);
return InterceptorMethod.endKafkaPollAndInvokeIteration(ret);
}
@Override
......
......@@ -26,20 +26,30 @@ import org.apache.skywalking.apm.plugin.kafka.define.InterceptorMethod;
import java.lang.reflect.Method;
/**
* The interceptor intends to be imposed on the method `processSeeks` in the ListenerConsumer class
* defined in {@link org.springframework.kafka.listener.KafkaMessageListenerContainer}
*/
public class ProcessSeeksMethodInterceptor implements InstanceMethodsAroundInterceptor {
private static final String OPERATION_NAME = "/spring-kafka" + Constants.KAFKA_POLL_AND_INVOKE_OPERATION_NAME;
/**
* The `beforeMethod` is called before `processSeeks`, which can be used to mark the end of the last iteration.
*/
@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
MethodInterceptResult result) throws Throwable {
InterceptorMethod.afterMethod(null);
InterceptorMethod.endKafkaPollAndInvokeIteration(null);
}
/**
* The `afterMethod` is called after `processSeeks`, where the new PollAndInvoke iteration starts
*/
@Override
public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
Object ret) throws Throwable {
InterceptorMethod.beforeMethod(OPERATION_NAME);
InterceptorMethod.beginKafkaPollAndInvokeIteration(OPERATION_NAME);
return ret;
}
......
......@@ -33,13 +33,13 @@ public class PollAndInvokeMethodInterceptor implements InstanceMethodsAroundInte
@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
MethodInterceptResult result) throws Throwable {
InterceptorMethod.beforeMethod(OPERATION_NAME);
InterceptorMethod.beginKafkaPollAndInvokeIteration(OPERATION_NAME);
}
@Override
public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
Object ret) throws Throwable {
return InterceptorMethod.afterMethod(ret);
return InterceptorMethod.endKafkaPollAndInvokeIteration(ret);
}
@Override
......
......@@ -33,13 +33,13 @@ public class KafkaOnMessageAnnotationMethodInterceptor implements InstanceMethod
@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
MethodInterceptResult result) throws Throwable {
InterceptorMethod.beforeMethod(OPERATION_NAME);
InterceptorMethod.beginKafkaPollAndInvokeIteration(OPERATION_NAME);
}
@Override
public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
Object ret) throws Throwable {
return InterceptorMethod.afterMethod(ret);
return InterceptorMethod.endKafkaPollAndInvokeIteration(ret);
}
@Override
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册