Class WebClientTracer
java.lang.Object
overit.geocall.spring.trace.client.WebClientTracer
Implementation of filter that trace some generic information
(included the content when available) about the request performed by the
WebClient.
The operation can be described in two stages:
- capture: in the capture phase, the trace is registered within the client filters and stores some information internally such as headers, URL and message content (when possible)
- trace: the trace phase occurs after the completion of the request and deals with making the captured
information persistent, through the
IOLogTracer
Following, there's an usage example
@Service
public class ClientService {
@Autowired
WebClientTracer tracer;
public void findAll() {
var entity = WebClient.builder()
.filter(tracer.capture()) // 1 - CAPTURE
.build()
.get()
.uri("https://hostname:8080/resource")
.retrieve()
.toEntity(Map.class)
.block();
tracer.trace(); // 2 - TRACE
}
}
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.web.reactive.function.client.ExchangeFilterFunctioncapture()Capture the information about request and responsevoidtrace()Deals with making the captured information persistent, through theIOLogTracer
-
Constructor Details
-
WebClientTracer
Create a newWebClientTracerinstance- Parameters:
mapper- mapper used to serialize headers info
-
-
Method Details
-
capture
public org.springframework.web.reactive.function.client.ExchangeFilterFunction capture()Capture the information about request and response- Returns:
- an ExchangeFilterFunction used to capture the information about request and response
-
trace
public void trace()Deals with making the captured information persistent, through theIOLogTracer
-