Search code examples
springspring-bootspring-cloud-sleuthaxonaxon-framework

spring-cloud-starter-sleuth + axon-tracing-spring-boot-starter =?


The title says it all. Is it possible to get spring-cloud-starter-sleuth working together with axon-tracing-spring-boot-starter?

current log output:

    2021-06-02 15:12:36.449  INFO [,2b2fc6a322588b0e,114b332e7847e95f] 14716 --- [nio-8082-exec-5] o.a.m.interceptors.LoggingInterceptor    : Dispatched messages: [FindAll]
2021-06-02 15:12:36.455  INFO [,,] 14716 --- [ueryProcessor-9] o.a.m.interceptors.LoggingInterceptor    : Incoming message: [FindAll]
2021-06-02 15:12:36.542  INFO [,,] 14716 --- [ueryProcessor-9] o.a.m.interceptors.LoggingInterceptor    : [FindAll] executed successfully with a [ArrayList] return value
2021-06-02 15:12:36.668  INFO [,2b2fc6a322588b0e,114b332e7847e95f] 14716 --- [nio-8082-exec-5] o.a.m.interceptors.LoggingInterceptor    : Dispatched messages: [KlassificeraApplikationCommand]
2021-06-02 15:12:36.724  INFO [,,] 14716 --- [mandProcessor-0] o.a.m.interceptors.LoggingInterceptor    : Incoming message: [KlassificeraApplikationCommand]
2021-06-02 15:12:36.785  INFO [,,] 14716 --- [mandProcessor-0] o.a.m.interceptors.LoggingInterceptor    : [KlassificeraApplikationCommand] executed successfully with a [null] return value
2021-06-02 15:12:36.785  INFO [,,] 14716 --- [mandProcessor-0] o.a.m.interceptors.LoggingInterceptor    : Dispatched messages: [ApplikationKlassificeradEvent]
2021-06-02 15:12:36.808 TRACE [,2b2fc6a322588b0e,114b332e7847e95f] 14716 --- [nio-8082-exec-5] org.zalando.logbook.Logbook              : Incoming Request: null

desired log output:

2021-06-02 15:12:36.449  INFO [,2b2fc6a322588b0e,114b332e7847e95f] 14716 --- [nio-8082-exec-5] o.a.m.interceptors.LoggingInterceptor    : Dispatched messages: [FindAll]
2021-06-02 15:12:36.455  INFO [,2b2fc6a322588b0e,114b332e7847e95f] 14716 --- [ueryProcessor-9] o.a.m.interceptors.LoggingInterceptor    : Incoming message: [FindAll]
2021-06-02 15:12:36.542  INFO [,2b2fc6a322588b0e,114b332e7847e95f] 14716 --- [ueryProcessor-9] o.a.m.interceptors.LoggingInterceptor    : [FindAll] executed successfully with a [ArrayList] return value
2021-06-02 15:12:36.668  INFO [,2b2fc6a322588b0e,114b332e7847e95f] 14716 --- [nio-8082-exec-5] o.a.m.interceptors.LoggingInterceptor    : Dispatched messages: [KlassificeraApplikationCommand]
2021-06-02 15:12:36.724  INFO [,2b2fc6a322588b0e,114b332e7847e95f] 14716 --- [mandProcessor-0] o.a.m.interceptors.LoggingInterceptor    : Incoming message: [KlassificeraApplikationCommand]
2021-06-02 15:12:36.785  INFO [,2b2fc6a322588b0e,114b332e7847e95f] 14716 --- [mandProcessor-0] o.a.m.interceptors.LoggingInterceptor    : [KlassificeraApplikationCommand] executed successfully with a [null] return value
2021-06-02 15:12:36.785  INFO [,2b2fc6a322588b0e,114b332e7847e95f] 14716 --- [mandProcessor-0] o.a.m.interceptors.LoggingInterceptor    : Dispatched messages: [ApplikationKlassificeradEvent]
2021-06-02 15:12:36.808 TRACE [,2b2fc6a322588b0e,114b332e7847e95f] 14716 --- [nio-8082-exec-5] org.zalando.logbook.Logbook              : Incoming Request: null

Solution

  • It seems axon-tracing-spring-boot-starter is using OpenTracing. OpenTracing is a tracing library that was abandoned and it has never reached a GA/stable release. So even if there would be an easy way, I would not use OpenTracing in production, I would try to move away from it.

    From version 3.0, Spring Cloud Sleuth has abstracted the tracer away and it supports multiple tracer implementations. By default it supports Brave which is a mature tracing library but Sleuth has support for OpenTelemetry as well (Sleuth-OTel). The OpenTelemetry support is incubating and it is not recommended to use in prod since OpenTelemetry Tracing is not entirely stable/GA yet for Java.

    With this, your options are:

    1. Add support to Axon for Brave
      This is what I would recommend, I would start with opening an issue for them
    2. OpenTelemetry theoretically compatible with OpenTracing (check the OpenTelemetry docs)
      You might be able to use Sleuth-OTel and OpenTracing The problem with this is: OpenTracing is abandoned and never went GA, OpenTelemetry Java Tracing is not stable yet, Sleuth-OTel is not stable yet
    3. You can implement OpenTracing support for Sleuth
      I think this is a bad idea, it is a lot of work and OpenTracing is abandoned and never went GA