Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Jaeger with Spring WebFlux?

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.

like image 580
Anoop Hallimala Avatar asked Oct 22 '25 04:10

Anoop Hallimala


1 Answers

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

like image 108
Anoop Hallimala Avatar answered Oct 25 '25 06:10

Anoop Hallimala



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!