spring-framework
spring-framework copied to clipboard
Missing trace/span on certain exceptions in DispatcherServlet using ObservationAutoConfiguration
On certain errors we don't get traces/spans in log statements. This happens when using latest Spring Boot 3.3.4 with ObservationAutoConfiguration and the following dependencies (example repo here):
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-tracing-bridge-brave</artifactId>
</dependency>
And the following correlation pattern is configured in application.properties:
logging.pattern.correlation=[${spring.application.name:},%X{traceId:-},%X{spanId:-}]
When starting up the application and running this (invalid) request
curl -X PUT http://localhost:8080/test -H "Content-Type: application/x-www-form-urlencoded" --data " %@ "
...we see the following log entry without trace/span:
2024-10-08T13:08:15.510+02:00 ERROR 7602 --- [nio-8080-exec-4] [demo3,,] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception
Note: logging the happy path works fine.