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

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

标题说明了一切。是否可以让 spring-cloud-starter-sleuth 与 axon-tracing-spring-boot-starter 一起工作?

当前日志输出:

    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

期望的日志输出:

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

似乎 axon-tracing-spring-boot-starter 正在使用 OpenTracing。 OpenTracing 是一个被遗弃的跟踪库,它从未达到 GA/stable 版本。所以即使有一个简单的方法,我也不会在生产中使用 OpenTracing,我会尝试远离它。

从 3.0 版开始,Spring Cloud Sleuth 将跟踪器抽象化,并支持多种跟踪器实现。默认情况下,它支持 Brave,这是一个成熟的跟踪库,但 Sleuth 也支持 OpenTelemetry (Sleuth-OTel)。 OpenTelemetry 支持正在孵化,不建议在产品中使用,因为 OpenTelemetry Tracing 还不完全 stable/GA Java.

有了这个,您的选择是:

  1. 为 Brave 添加对 Axon 的支持
    这是我会推荐的,我将从为他们打开一个问题开始
  2. OpenTelemetry 理论上与 OpenTracing 兼容(查看 OpenTelemetry 文档)
    您也许可以使用 Sleuth-OTel 和 OpenTracing 问题是:OpenTracing 被放弃并且从未进入 GA,OpenTelemetry Java Tracing 还不稳定,Sleuth-OTel 还不稳定
  3. 您可以为 Sleuth 实现 OpenTracing 支持
    我认为这是个坏主意,需要做很多工作,而且 OpenTracing 已被放弃并且从未进入 GA