问题
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