I have a Spring Boot 3.1.1 project using Axon 4.8.2, when I add the OTEL library for tracing I suddenly get the following error upon starting the application:
Caused by: org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'spanFactory' is expected to be of type 'org.axonframework.tracing.SpanFactory' but was actually of type 'org.axonframework.tracing.opentelemetry.OpenTelemetrySpanFactory'
I have added no configuration for OTEL in any way, just trying to let it autowire itself.
Anyone seen this before? Seems, from other examples I’ve seen like the AxonIQ opentelemetry-samples repo, that this should work out of the box?
Hello @milehimikey. Sorry to hear you are running into this kind of trouble!
I’ve just tried it out to see if it had anything to do with Spring versions, but it seems to work for me locally. Would it be possible to provide me with a minimum reproducible sample so I can investigate?
OpenTelemetrySpanFactory has SpanFactory as an interface so it should work. What versions of axon-messaging and axon-tracing-opentelemetry do you have exactly? Perhaps it has to do with some of the changes we made to the interface in regards to a thread leak in its design.
Hello @milehimikey! Thanks for creating the sample, it is very much appreciated.
The cast seems valid, definitely! However, nothing is as it seems in the realms of Spring Boot Devtools. The classes are part of different classloaders, and thus don’t implement each other.
I tried your code with 4.9.0-SNAPSHOT and it works. We will be backporting the fix to a 4.8.x release somewhere this week as the 4.9.0 release is still too far away and more people will start using the new Spring tooling. Until then you can run a snapshot version yourself (but there is no BOM), or you have to wait until later this week.