英文:
ElasticApmInstrumentation matcher constructor super
问题
有可能为ElasticApmInstrumentation编写匹配器,只捕获子类的构造函数吗?
我的意思是,我目前使用 ElementMatcher.isConstructor()
,但某些类在构造函数调用中使用 super()
,这会触发对相同对象的调用。
如果存在更多层级,我会得到更多重复。有办法避免这种情况吗?
请注意,作为类的匹配器,我需要使用父类来捕获整个类组。
英文:
Is it possible to write matcher for ElasticApmInstrumentation that will capture constructor of child class only?
I mean currently I use ElementMatcher.isConstructor()
but some classes use in the constructor call super()
and this triggers call of on the same object.
In case there are more levels I get even more duplications.
Is there a way how to avoid it?
Please note as a matcher for class I need to use parent class to capture whole group of classes.
答案1
得分: 1
匹配是基于形状而非实现完成的。由于这个原因,这是不可能的。
英文:
The matching is done based on the shape, not the implementation. This is not possible for this reason.
答案2
得分: 0
使用@Advice.Origin("#t")
和@Advice.This
实例,我能够实现它。
然后我比较了origin.equals(instance.getClass().getName())
。
我无法直接避免对代码的仪器化,但我可以筛选掉重复部分。
英文:
I was able to achieve it by using @Advice.Origin("#t")
origin and @Advice.This
instance.
Then I compared origin.equals(instance.getClass().getName())
.
I was not able to avoid the instrumentation directly but I was able to filter out duplications.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论