Replies: 39 comments 8 replies
-
The key question is why? Filter and enhancement is a very expansive operation, especially in the runtime. For what purpose, you want to enhance a class twice and for a specific method? |
Beta Was this translation helpful? Give feedback.
-
Current codes work well if you are targeting different methods. |
Beta Was this translation helpful? Give feedback.
-
Let me talk about the application scenario: the Jedis plugin for Skywalking, for example, now only has the call chain function. Now we have a new requirement, full link test(全链路压测), we need to create the shadow database, that is, during the Jedis call, we need to intercept and switch the shadow database, this logic, we do not want to put together with the previous Jedis plug-in, we want to be a new, separate plug-in. |
Beta Was this translation helpful? Give feedback.
-
@tristaZero See! What I was saying :) People are using this case. @stateIs0 If you are talking about shadow database and mock data flag propagation, that is a thing I have designed and discussed with Apache ShardingSphere. I hope they could collaborate to process this, which will be much cooler and no need for the thing you asked about repeated instrumentation. |
Beta Was this translation helpful? Give feedback.
-
Thank you. Now I want to discuss two issues:
|
Beta Was this translation helpful? Give feedback.
-
We haven't opened the design. @tristaZero I hope we could work together on this. Are you sure we could do this now? |
Beta Was this translation helpful? Give feedback.
-
Hi @wu-sheng , Right...I stand on your side. It is a great feature worthy of two communities' collaboration. |
Beta Was this translation helpful? Give feedback.
-
@wu-sheng
The pseudocode is as follows: @RuntimeType
public Object trace(@This Object obj,
@AllArguments Object[] allArguments,
@Origin Method method,
@SuperCall Callable<?> zuper) throws Throwable {
if (cache.get(method) != null) {
return cache.get(method).invoke(new ParamModel(obj, allArguments, method, zuper));
}
List<Builder.Interceptor> interceptorList = new ArrayList<>();
for (Builder.Interceptor interceptor : interceptors) {
List<ElementMatcher<MethodDescription>> matches = interceptor.matches();
for (ElementMatcher<MethodDescription> match : matches) {
// 找到能够匹配这个方法的拦截器.
if (match.matches(new MethodDescription.ForLoadedMethod(method))) {
interceptorList.add(interceptor);
}
}
}
// 排序
interceptorList.sort(Comparator.comparingInt(Builder.Interceptor::order));
List<ChainFactory.Filter<Object, ParamModel>> list = new ArrayList<>();
// 将每个拦截器用 filter 包装起来
for (Builder.Interceptor interceptor : interceptorList) {
list.add((target, arg) -> {
// before
interceptor.beforeMethod(arg.obj, arg.method, arg.allArguments, method.getParameterTypes(), new MethodInterceptResult());
Object result = null;
try {
// 下个过滤器进行调用
result = target.invoke(arg);
} catch (Throwable throwable) {
interceptor.handleMethodException(arg.obj, arg.method, arg.allArguments, method.getParameterTypes(), throwable);
}
// after
interceptor.afterMethod(arg.obj, arg.method, arg.allArguments, method.getParameterTypes(), result);
return result;
});
}
// 构建过滤器链, 并添加尾部节点. 尾部节点直接调用目标方法.
ChainFactory.Invoker<Object, ParamModel> chain = ChainFactory.build(list, paramModel -> paramModel.zuper.call());
// 发起调用.
Object result = chain.invoke(new ParamModel(obj, allArguments, method, zuper));
return result;
} |
Beta Was this translation helpful? Give feedback.
-
Hello, thanks for your advice. However, we are not only a database, but also Shadow libraries such as ES, Redis, Pika, MQ and so on. Shadow DB is not a universal solution |
Beta Was this translation helpful? Give feedback.
-
I was not asking about this multi-interceptors support, I was asking about are you adding this because you could route the data into the shadow database? |
Beta Was this translation helpful? Give feedback.
-
yes, i need |
Beta Was this translation helpful? Give feedback.
-
I know you need, my question is whether this is your only reason to do so? |
Beta Was this translation helpful? Give feedback.
-
@wu-sheng @tristaZero |
Beta Was this translation helpful? Give feedback.
-
yes,you are right,Thank you for your reply. 😀 |
Beta Was this translation helpful? Give feedback.
-
Let's keep this issue open, if someone at ShardingSphere side is ready to join, we could initialize the process. |
Beta Was this translation helpful? Give feedback.
-
Looking forward to your design proposal very much! |
Beta Was this translation helpful? Give feedback.
-
Excuse me, I ran into a similar problem, but, not a full link pressure testing scenario。
the subEnvAgent and infoCollectAgent is written based on skywalking。 However, as the number of agents grows, it becomes more difficult to maintain all agents. In the end, we decided to merge all agents to one。Because of this, the problems mentioned above comed。 skywalkingAgent and infoCollectAgent both define a plugin for the same class at the same time, but skywalking 's responsibility is for trace collection, and infoCollectAgent is to collect other information。At this time, only one plugin will take effect。 To solve this problem, we made a change similar to @stateIs0 has did。 In my opinion, maybe for extension of skywalking, multi-interceptors should be supported。 |
Beta Was this translation helpful? Give feedback.
-
Hi, if you want to discuss, more importantly, contribute this feature), please open another issue to discuss. This issue is purely tracking for synthetic monitoring. We are working on this way, check the linked issues from ShardingSphere community. |
Beta Was this translation helpful? Give feedback.
-
Yes,I am glad to do this. I will open another issue later |
Beta Was this translation helpful? Give feedback.
-
Hi @daimingzhi , Thanks for your attention. It is on the way to do mock traffic test on pro env leveraging Skywalking and ShardingSphere. Plus, I guess we need more future communication among all the people involved. |
Beta Was this translation helpful? Give feedback.
-
@tristan-tsl I think @daimingzhi was asking for a different thing, but matched here because there was a potential proposal having a similar feature requirement. Besides that, I agree that, we should set up a GitHub org to host all Synthetic Monitoring related things, otherwise, people are going to confuse where they are showing up to talk about this specific use case. |
Beta Was this translation helpful? Give feedback.
-
I see, it is true that people will confuse when asking questions. |
Beta Was this translation helpful? Give feedback.
-
Yes,My current job is to maintain our company's javaAgents based on SkyWalking, @tristaZero I am afraid I do not have enough time to know more about ShardingSphere. What I said above is to better the extension of SkyWalking. @wu-sheng I hope I can participate in the development or maintenance of the skyWalking kernel module in the future.Maybe this is my first step.I have opend another issue Discussion about multi-interceptors supporting in SkyWalking |
Beta Was this translation helpful? Give feedback.
-
@tristaZero @mrproliu I am moving this to discussion panel, welcome to continue there. As this is going to be a separate release project, SkyWalking community would recommend users to continue on that repo once Juan creates that. |
Beta Was this translation helpful? Give feedback.
-
Hi @wu-sheng and guys, Sorry for my delayed reply, but good news, we almost finish refactoring Shadow database feature. ;-) @soulasuna will update more later. Look forward to our next step. |
Beta Was this translation helpful? Give feedback.
-
Conclusion to this discussion, all following process moves to official repo, https://github.com/SphereEx/CyborgFlow |
Beta Was this translation helpful? Give feedback.
-
Hi, update here. |
Beta Was this translation helpful? Give feedback.
-
Please answer these questions before submitting your issue.
Question
Sorry, first of all, my English is not good, this is the use of software translation. The specific issues are as follows:
Why doesn't Skywalking's plug-in use filter chain mode? In current mode, if you want to enhance the same class twice, you may not be able to determine the order and may even report an error.
Would it be more extension-friendly if you could support two enhancements to the same class, and control the order? In fact, in our project, we have already started to modify this piece to support filter chains.
Beta Was this translation helpful? Give feedback.
All reactions