Automatic context propagation fails in error handler ErrorWebExceptionHandler #34357
Labels
for: external-project
Needs a fix in external project
in: web
Issues in web modules (web, webmvc, webflux, websocket)
status: invalid
An issue that we don't feel is valid
theme: observability
An issue related to observability and tracing
Spring: 6.1.1
Spring Boot: 3.2.0
Spring Cloud Gateway: 4.1.0
Project Reactor Core: 3.6.0
Micrometer context-propagation: 1.1.2
We have develop API Gateway application using Spring Cloud Gateway framework.
We have used Logback library for logging purpose and integrated MDC for contextual diagnostic information (like request tracking id) propagation in log messages.
We have used automatic context propagation feature of context-propagation library in order to implement MDC contextual diagnostic mapping in reactive style.
Application Main Class Code Snippet:
Filter class with Reactive Context Write:
Exception is thrown in the filter that is after request tracking id is uploaded in Reactive Context above.
The automatic context propagation is working correctly in the normal processing of request by the application using MDC and logback libraries, however it seems not working when any exception/error is thrown during the request processing.
We have implemented custom exception handler by implementing ErrorWebExceptionHandler handle(exchange, exception) method. Now we observe that the request tracking id is not getting logged in any of log messages written in the statements of custom exception handler.
We found following similar issue reported in this community however it is marked as fixed in Spring 6.1.0-M1 release:
#30013
Tried to search for the proper solution for the issue however unable to find the fix for it.
Any help would be highly appreciated. Thanks in advance.
The text was updated successfully, but these errors were encountered: