1
votes

I'm wondering whether sleuth has reactive WebClient instrumentation supported.

I did't find it from the document:

Instruments common ingress and egress points from Spring applications (servlet filter, async endpoints, rest template, scheduled actions, message channels, Zuul filters, and Feign client).

My case:

I may use WebClient in either a WebFilter or my rest resource to produce Mono.

And I want:

  • A sub span auto created as child of root span
  • trace info propagated via headers

If the instrumentation is not supported at the moment, Am I supposed to manually get the span from context and do it by myself like this:

OpenTracing instrumentation on reactive WebClient

Thanks

Leon

2

2 Answers

7
votes

Even though this is an old question this would help others...

WebClient instrumentation will only work if new instance is created via Spring as a Bean. Check 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.

1
votes

If you go to Sleuth's documentation for the Finchley release train, and you do find and you search for WebClient you'll find it - https://cloud.spring.io/spring-cloud-static/Finchley.RC2/single/spring-cloud.html#__literal_webclient_literal . In other words we do support it out of the box.