Add ServerWebExchange getter in WebFlux Observation context
The observation context relies on request and response for propagation, but the exchange itself holds attributes and locale context so this is needed for keyvalues extraction in general. This commit adds a getter to expose the exchange from the context.
This commit is contained in:
parent
68246dc72c
commit
7e0a039291
|
@ -35,6 +35,8 @@ import org.springframework.web.util.pattern.PathPattern;
|
|||
*/
|
||||
public class ServerRequestObservationContext extends RequestReplyReceiverContext<ServerHttpRequest, ServerHttpResponse> {
|
||||
|
||||
private final ServerWebExchange serverWebExchange;
|
||||
|
||||
@Nullable
|
||||
private PathPattern pathPattern;
|
||||
|
||||
|
@ -42,10 +44,18 @@ public class ServerRequestObservationContext extends RequestReplyReceiverContext
|
|||
|
||||
public ServerRequestObservationContext(ServerWebExchange exchange) {
|
||||
super((request, key) -> request.getHeaders().getFirst(key));
|
||||
this.serverWebExchange = exchange;
|
||||
setCarrier(exchange.getRequest());
|
||||
setResponse(exchange.getResponse());
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the current {@link ServerWebExchange HTTP exchange}.
|
||||
*/
|
||||
public ServerWebExchange getServerWebExchange() {
|
||||
return this.serverWebExchange;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the path pattern for the handler that matches the current request.
|
||||
* For example, {@code "/projects/{name}"}.
|
||||
|
|
Loading…
Reference in New Issue