TraceId is not propogated on Error, after spring cloud version >= 2021.0.6
sankarg931190 opened this issue · 1 comments
Describe the bug
In my application we were providing traceId back to client when response code is 4XX and 5XX. In Spring cloud version 2021.0.6 & 2021.0.7, the traceId is lot and while retrieving currentSpan we are getting NPE.
I was comparing TrackWebFilter class in Spring Cloud Sleuth Instrumentation for version 3.1.5( which is used in Spring cloud version 2021.0.5) and version 3.1.8 (which is used in Spring cloud version 2021.0.7). The OnError call invokes "terminateSpan" method, which thereby removes span from the tracer object. This change was introduced as part of below fix, https://github.com/spring-cloud/spring-cloud-sleuth/pull/2275/files
I understand the code change was intended for OnComplete, but it has been applied for OnError as well, which causes spanid to be null and propagation of the span id is lost.
Is it possible to revert those changes for OnError.
@sankarg931190 can you please provide a reproducer?
Thanks,
Oleh