Spring boot Sleuth在b3单头中不包括RabbitMQ消息的ParentSpan
我最近从Spring Cloud Greenwich.SR2迁移到Hoxton.SR9,并使用Spring Sleuth跟踪传入的REST调用到我的Spring Boot应用程序,该应用程序触发最终到达RabbitMQ的消息 显然,Spring Sleuth在这两个版本之间的一个关键区别是,不再为trace、span和parentSpan发送3个单独的消息头,现在只发送一个Spring boot Sleuth在b3单头中不包括RabbitMQ消息的ParentSpan,spring-boot,spring-cloud-sleuth,Spring Boot,Spring Cloud Sleuth,我最近从Spring Cloud Greenwich.SR2迁移到Hoxton.SR9,并使用Spring Sleuth跟踪传入的REST调用到我的Spring Boot应用程序,该应用程序触发最终到达RabbitMQ的消息 显然,Spring Sleuth在这两个版本之间的一个关键区别是,不再为trace、span和parentSpan发送3个单独的消息头,现在只发送一个b3头,形式为{trace}-{span}-{sample}-{parentSpan},最后两个组件是可选的 让我困惑的是,
b3
头,形式为{trace}-{span}-{sample}-{parentSpan}
,最后两个组件是可选的
让我困惑的是,到达RabbitMQ的消息上的b3头似乎从来没有parentSpan组件。e、 g.顺序如下:
spring.sleuth.enabled=true
spring.messaging.enabled=true
spring.supportsJoin=false
(注意:我在supportsJoin defaulted上也做了同样的尝试,但对于缺少parentSpanId似乎没有任何影响)
调试信息
这是我通过单步执行调试器所能确定的:
GenericMessage
传递到AbstractMessageChannel.send()
TracingChannelInterceptor.preSend()
TracingChannelInterceptor
配置了一个DeferredInjector
,其中setter
是MessageHeaderPropagation
的一个实例,而injectorFactory
具有一个producerinjector函数=单个父对象
TracingChannelInterceptor.preSend()
方法调用DeferredInjector.inject(span.context(),headers)
,这导致单\u NO \u父注入器向传出消息添加一个b3
头,格式为{traceId}-{spanId}-1
@Configuration
public class B3Configuration {
@Bean
Propagation.Factory customPropagationFactory() {
return B3Propagation.newFactoryBuilder()
.injectFormat(B3Propagation.Format.SINGLE)
.injectFormat(Span.Kind.CLIENT, B3Propagation.Format.SINGLE)
.injectFormat(Span.Kind.CONSUMER, B3Propagation.Format.SINGLE)
.injectFormat(Span.Kind.PRODUCER, B3Propagation.Format.SINGLE)
.build();
}
}
默认的
b3.Format
似乎已更改,您可以在以下位置看到当前的格式:
//注意:您是否碰巧有一个复制该问题的示例项目?Hi Jonatan-我现在没有什么东西,但如果有帮助的话,我可能会把一些简单的东西放在一起。Spring Boot 2.3.7和Spring Cloud Hoxton.SR9是一个非常普通的Spring Boot设置。目前我还没有找到源代码,但我确实尝试在Spring Boot应用程序中调试了它,它使用了Format.SINGLE\u NO\u PARENT,而不是Format.SINGLE,在传出Spring消息的拦截器上下文中使用Format.SINGLE。很抱歉,我现在不能说得更具体。@JonatanIvanov我在原始问题中添加了一些调试信息,希望对您有所帮助-如果您需要更多信息,请告诉我。@JonatanIvanov“问题”(如果是问题)似乎是通过注册问题文本中包含的bean来解决的。但是我很惊讶我必须这样做才能让它这样工作。感谢您查看这个@JonatanIvanov,以及关于使用BaggagePropagation.newFactoryBuilder
的有用建议。我查看了问题链接,但不确定结论-这种默认行为(使用单亲家长)正确吗?结果对我来说似乎很奇怪。