[improvement,feature] Support groovy code with the annotation API:#567
[improvement,feature] Support groovy code with the annotation API:#567felixbarny merged 2 commits intoelastic:masterfrom
Conversation
groovyc can't see the same class headers javac can, so the annotations must survive the compilation process to be seen by bytebuddy
|
Hi @fredgalvao, we have found your signature in our records, but it seems like you have signed with a different e-mail than the one used in your Git commit. Can you please add both of these e-mails into your Github profile (they can be hidden), so we can match your e-mails to your Github profile? |
|
Sorry for the diff email thing. I've now fixed it. |
|
Oh, boy, I can’t believe this oversight 🤦 Thanks a lot for investigating. I’m wondering how this has ever worked. While at it, could you also add the |
Codecov Report
@@ Coverage Diff @@
## master #567 +/- ##
============================================
- Coverage 62.19% 62.15% -0.05%
+ Complexity 1264 68 -1196
============================================
Files 185 185
Lines 6994 7002 +8
Branches 810 811 +1
============================================
+ Hits 4350 4352 +2
- Misses 2370 2374 +4
- Partials 274 276 +2
Continue to review full report at Codecov.
|
|
My pleasure to help ;)
#metoo
Done. |
As per https://discuss.elastic.co/t/kibana-apm-not-showing-capturespan-and-capturetransaction/173026 and a few other tests I did myself in the last few weeks, apm-agent-java couldn't support code that went through groovyc with the annotation API (
CaptureSpan,CaptureTransaction). I initially only saw that the annotations weren't making it to the final.classfile, but couldn't investigate properly at the time.It was only recently that I noticed that there was no
RetentionPolicyfor these two annotations, which was making the defaultRetentionPolicy#CLASSthe chosen one, which can't really be seen during runtime by bytebuddy for things it doesn't fully understand. See this for more details on this, even though I can't really explain why bytebuddy would see it for java classes during runtime...Changing the
RetentionPolicytoRUNTIMEenables everything I wanted and could test:@CompileStaticTests were already failing on my machine on master, so I really don't know if I could ever break anything with this change, but I'm willing to bet it will be inoffensive.