ElasticApmInstrumentation匹配器构造函数super

huangapple go评论43阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2023年5月25日 22:39:06
  • 转载请务必保留本文链接:https://go.coder-hub.com/76333505.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定