spring 侦探中的 WebClient 检测

WebClient instrumentation in spring sleuth

我想知道 sleuth 是否支持响应式 WebClient 检测。

我在文档中没有找到:

检测来自 Spring 应用程序(servlet 过滤器、异步端点、rest 模板、计划操作、消息通道、Zuul 过滤器和 Feign 客户端)的常见入口和出口点。

我的情况:

我可以在 WebFilter 或我的其余资源中使用 WebClient 来生成 Mono。

我想要:

如果目前不支持检测,我是否应该手动从上下文中获取跨度并自己这样做:

OpenTracing instrumentation on reactive WebClient

谢谢

里昂

如果您转到 Sleuth 的 Finchley 发布系列文档,然后执行 find 并搜索 WebClient,您会找到它 - https://cloud.spring.io/spring-cloud-static/Finchley.RC2/single/spring-cloud.html#__literal_webclient_literal。换句话说,我们开箱即用地支持它。

更新:

新 link - https://docs.spring.io/spring-cloud-sleuth/docs/current/reference/html/integrations.html#sleuth-http-client-webclient-integration

让我把内容贴出来

3.2.2. WebClient

This feature is available for all tracer implementations.

We inject a ExchangeFilterFunction implementation that creates a span and, through on-success and on-error callbacks, takes care of closing client-side spans.

To block this feature, set spring.sleuth.web.client.enabled to false. You have to register WebClient as a bean so that the tracing instrumentation gets applied. If you create a WebClient instance with a new keyword, the instrumentation does NOT work.

尽管这是一个老问题,但这对其他人有帮助...

WebClient 检测仅在通过 Spring 作为 Bean 创建新实例时才有效。检查 Spring Cloud Sleuth reference guide.

You have to register WebClient as a bean so that the tracing instrumentation gets applied. If you create a WebClient instance with a new keyword, the instrumentation does NOT work.