How to use Jaeger with Spring WebFlux?

依然范特西╮ 提交于 2019-12-21 20:24:21

问题


We are trying to go reactive with Webflux. We are using Jaegar with Istio for instrumentation purposes.

Jaegar understands Spring MVC endpoints well, but don't seem to work at all for WebFlux.

I am looking for suggestions to make my webflux endpoints appear in Jaeger.

Thanks in advance.


回答1:


The best way to move forward in order to use Jaegar is NOT TO USE JAEGAR CLIENT!

Jaegar has the ability to collect Zipkin spans:

https://www.jaegertracing.io/docs/1.8/getting-started/#migrating-from-zipkin

You should take advantage of this and use the below Sleuth+Zipkin dependency and exclude Jaegar agent jars in your spring boot app.

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-sleuth-zipkin</artifactId>
</dependency>

The above will send Zipkin spans to http://localhost:9411 by default. You can override this in your Spring Boot app to point to your Jaegar server easily by overriding the zipkin base URL.

spring.zipkin.base-url=http://your-jaegar-server:9411

Sleuth will do all the heavy lifting and the default logging will log the span and traceIds.

In the log4j2.xml file, all you have to mention is

[%X]

You can find the sample code here:

https://github.com/anoophp777/spring-webflux-jaegar-log4j2



来源:https://stackoverflow.com/questions/53322900/how-to-use-jaeger-with-spring-webflux

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!