[improvement,feature] Support groovy code with the annotation API: #567
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
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.