anuni
anuni

Reputation: 999

WebClient instrumentation in spring sleuth

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:

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

Upvotes: 1

Views: 4245

Answers (2)

Marcin Grzejszczak
Marcin Grzejszczak

Reputation: 11149

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.

UPDATE:

New link - https://docs.spring.io/spring-cloud-sleuth/docs/current/reference/html/integrations.html#sleuth-http-client-webclient-integration

let me paste the contents

3.2.2. WebClient

This feature is available for all tracer implementations.

We inject a ExchangeFilterFunction implementation that creates a span and, through on-success and on-error callbacks, takes care of closing client-side spans.

To block this feature, set spring.sleuth.web.client.enabled to false. 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.

Upvotes: 2

Chathurika Sandarenu
Chathurika Sandarenu

Reputation: 1492

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.

Upvotes: 7

Related Questions