sleuth 是否与 retrofit2 兼容

Is sleuth compatible with retrofit2

spring-cloud-sleuth compatible with retrofit2吗?

我知道 sleuth 使用 spring MVC RestTemplate 开箱即用,但我无法在网上找到任何资源来了解如何使其与 retrofit2 一起使用。

据我所知,不幸的是。但我们愿意接收功能/拉取请求,所以请不要犹豫,在 https://github.com/spring-cloud/spring-cloud-sleuth/

中提交一个

您可以使用 Sleuth 配置的 HttpTracing bean 和 OkHttp

的实例对 brave 的 Call.Factory 进行改造
retrofitBuilder.callFactory(TracingCallFactory.create(httpTracing, okhttp))

https://github.com/openzipkin/brave/blob/master/instrumentation/okhttp3/README.md#tracingcallfactory https://github.com/square/retrofit/blob/63cf3e66c4b661170a34a396e9be8a2a01c0e57f/retrofit/src/main/java/retrofit2/Retrofit.java#L484

自从添加了以前的答案后,情况发生了变化。 OkHttpClient 和 Spring WebClient 对 Retrofit 的支持现在可以通过 Spring Cloud Square. You can find the documentation here. Information about Sleuth support can be found here.

获得