Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing response information from client observation context when filter functions fail #30247

Closed
bclozel opened this issue Mar 30, 2023 · 1 comment
Assignees
Labels
theme: observability An issue related to observability and tracing type: bug A general bug
Milestone

Comments

@bclozel
Copy link
Member

bclozel commented Mar 30, 2023

When a WebClient is configured with a custom ExchangeFilterFunction like this:

WebClient.builder().filter(new ExchangeFilterFunction() {
	@Override
	public Mono<ClientResponse> filter(ClientRequest request, ExchangeFunction next) {
		return next.exchange(request).flatMap(response -> {
			if (response.headers().header("X-Custom-Header").size() == 0) {
				return Mono.error(new IllegalStateException());
			}
			return Mono.just(response);
		});
	}
}).build();

The returned error will "short-circuit" the returned publisher and upstream subscriber will not see the HTTP response returned by the remote server. Since the observability instrumentation is done after the global ExchangeFunction (made of the ExchangeFunction of the HTTP connector, plus the ExchangeFilterFunction instances), the instrumentation will not see the response and will not set it on the ClientRequestObservationContext.

This means that while the recorded observations will contain the error returned by the filter, they will miss information about the actual remote server response.

@bclozel bclozel added type: bug A general bug theme: observability An issue related to observability and tracing labels Mar 30, 2023
@bclozel bclozel self-assigned this Mar 30, 2023
@bclozel bclozel added this to the 6.0.8 milestone Mar 30, 2023
@bclozel
Copy link
Member Author

bclozel commented Mar 30, 2023

Closed with d451d6a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme: observability An issue related to observability and tracing type: bug A general bug
Projects
None yet
Development

No branches or pull requests

1 participant