tracing icon indicating copy to clipboard operation
tracing copied to clipboard

SpanAspect does not take into account proxy objects

Open lex-em opened this issue 1 year ago • 5 comments

Hello. I tried to use @NewSpan on spring data repositories, but it idin't work

NewSpan newSpan = method.getAnnotation(NewSpan.class);

method here is from proxy and annotation not found.

I fixed that by using org.apache.commons.lang3.reflect.MethodUtils.getAnnotation(method, NewSpan::class.java, true, true)

Please fix them in library

lex-em avatar Jan 19 '24 06:01 lex-em

Can you create a simple reproducer for this issue or a test that shows that this doesn't work?

marcingrzejszczak avatar Jan 19 '24 10:01 marcingrzejszczak

@marcingrzejszczak reproducer with instructions in readme is here https://github.com/lex-em/micrometer-tracing-on-proxy CustomSpanAspect class contains additional comments

lex-em avatar Jan 23 '24 07:01 lex-em

@shakuzen @jonatan-ivanov what is your opinion on adding a dependency to apache commons to have this functionality? I guess we would need to do the same in micrometer for those aspects

marcingrzejszczak avatar Jan 25 '24 10:01 marcingrzejszczak

I'm thinking if:

  1. We can copy that single method: getAnnotation
  2. Document that methods like these should be either wrapped or .observed(methodReference) should be used
  3. Instrument Spring Data repositories

jonatan-ivanov avatar Feb 06 '24 19:02 jonatan-ivanov

That's not copying of just a single method :grimacing:

marcingrzejszczak avatar Feb 07 '24 09:02 marcingrzejszczak