Describe the bug When a REST request fails, duplicate traces are generated. This behavior exists for authentication errors (e.g. unauthenticated -> 401), as well as for other errors dispatching to the error page (e.g. wrong URL -> 404). It seems that requests which are dispatched to the error page by the framework, get a fresh observation and thus traceId, instead of taking any existing observation which was generated by the initial request handling.

The result in Grafana looks similar to this: example with 404 error-traces

Tested with SpringBoot 3.0.2, Spring Security 6.0.1

To Reproduce Fire a request against a secured RestController method, without authentication token. or Fire a request with a wrong URL which will result in a 404.

Expected behavior A single traceId should be generated, dispatched requests should reuse the original traceId