micrometer-metrics / tracing

Provides tracing abstractions over tracers and tracing system reporters.
https://micrometer.io
Apache License 2.0
241 stars 42 forks source link

@NewSpan/@SpanTag not working on Java interface methods #763

Open janchristian-haddorp opened 2 months ago

janchristian-haddorp commented 2 months ago

The combination @NewSpan/@SpanTag seems not fully working on interface methods - like Spring Data JPA repo methods (tested with latest Spring Boot 3.3.1 release).

Instead of creating a new span for the actual repo call and parent span is getting duplicated. All declared span tags are also added to parent span.

Not sure if this is really a Micrometer topic or if it is more Spring Boot related? Already asked there - first feedback was that most of the functionality comes from Micrometer.

However, I didn't find a hint on the Micrometer docs if/how @NewSpan/@SpanTag annotation can be added to Java interfaces.

shakuzen commented 2 months ago

Based on the tests and the corresponding documentation, it appears to be a known limitation that @NewSpan doesn't work on interfaces, though I'm not sure why that would be without looking into it more.

// In Sleuth @NewSpan and @ContinueSpan annotations would be taken into // consideration. In Micrometer Tracing due to limitations of @Aspect // we can't do that. The @SpanTag annotation will work well though.

We'll have to take a look and make sure the aspect-related code is in-sync between the Micrometer repo (where I believe this kind of thing works) and the tracing repo.