instrumentationbyte-buddyelastic-apm

ElasticApmInstrumentation matcher constructor 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.


Solution

  • 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.