I am implementing Open Telemetry for Spring Boot 4.0 (spring-boot-starter-opentelemetry) trying to follow https://spring.io/blog/2025/11/18/opentelemetry-with-spring-boot. I have a simple controller:
@RestController
@RequestMapping("/api")
public class Controller {
@GetMapping("/{id}")
public ResponseEntity<?> getById(@PathVariable String id) {
if ("1".equals(id)) {throw new RuntimeException("erro!!!!!");}
if ("2".equals(id)) {return ResponseEntity.notFound().build();}
if ("3".equals(id)) {return ResponseEntity.internalServerError().build();}
String message = "ID: " + id;
return ResponseEntity.ok(message);
}
}
The traces are being exported and I am able to view them in Grafana. When my controller throw a not handled error, like to id=1 I get a useful trace on Grafana, including a "Events" field with stack trace, exception type, etc:

However, when the exception is handled by controller, like for id=2 or id=3, the error info is not registered in the trace, and I get only:

I can´t get what is missing so I get the full trace with Events and error information when the error is being "treated"
My application.properties is
spring.application.name=demo
management.otlp.metrics.export.url=http://localhost:4318/v1/metrics
management.opentelemetry.tracing.export.otlp.endpoint=http://localhost:4318/v1/traces
management.opentelemetry.logging.export.otlp.endpoint=http://localhost:4318/v1/logs
management.observations.annotations.enabled=true
management.tracing.sampling.probability=1.0
and in my pom.xml I have:
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-opentelemetry</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webmvc</artifactId>
</dependency>
<dependency>
<groupId>io.opentelemetry.instrumentation</groupId>
<artifactId>opentelemetry-logback-appender-1.0</artifactId>
<version>2.21.0-alpha</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-opentelemetry-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webmvc-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
I also have an OpenTelemetryConfiguration, InstallOpenTelemetryAppender and TraceIdFilter as in the post https://spring.io/blog/2025/11/18/opentelemetry-with-spring-boot.