使用 Google Cloud Sleuth 2 进行 Span 自定义

Span Customization with Google Cloud Sleuth 2

有没有办法为 spring cloud sleuth 2 自定义 Span 注入和提取器? 在 1.2 版的文档中,我发现了一种在新版本 (2) 上不可用的方法。我想是因为现在它使用 Zipkin brave 来照顾 Span,对吧? https://cloud.spring.io/spring-cloud-sleuth/1.2.x/multi/multi__customizations.html#_example

我试图返回使用 spring cloud sleuth 的稳定版本 (1.3.3),但是当我将 bom 用于项目时,它在 spring 引导版本中发生冲突我正在使用(2.0)。它与 spring 启动版本 2?

兼容

我正在使用 spring 云侦探来跟踪我公司的服务,但我有一个跟踪其他服务的版本,它不能与 opentracing headers 压缩,所以我想要更改 http 消息的 headers 以使用我在其他组件中的当前跟踪 headers 使新服务可压缩。

谢谢

I tried to back to use the stable version(1.3.3) of spring cloud sleuth, but when i use the bom for the project its make conflict in the spring boot version that i am using(2.0). Its compactible with the spring boot version 2?

您不能将 Sleuth 1.3 与 Boot 2.0 一起使用。

I am using the spring cloud sleuth to make trace of services on my company, but i have a version of tracing on others services that is not compactible with the opentracing headers, so i want to change the headers of http messages to make the new services compactibles with the current tracing headers that i have in the others components.

是的,这就是 Brave 的变化。对于 http,您可以定义自己的解析。 https://github.com/spring-cloud/spring-cloud-sleuth/blob/master/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/web/TraceHttpAutoConfiguration.java#L57-L68

@Autowired HttpClientParser clientParser; @Autowired HttpServerParser serverParser; @Autowired @ClientSampler HttpSampler clientSampler; @Autowired(required = false) @ServerSampler HttpSampler serverSampler;

这些是您可以注册的采样器。

对于消息传递,您必须创建自己的全局通道拦截器版本 - 就像我们在此处定义的那样 - https://github.com/spring-cloud/spring-cloud-sleuth/blob/master/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/messaging/TraceSpringIntegrationAutoConfiguration.java#L49-L53 .

如果您不能接受,请继续在 Sleuth 中提交问题,以便我们可以在那里进行讨论。