Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing trace/span on certain exceptions in DispatcherServlet using ObservationAutoConfiguration #33667

Closed
geoludbit opened this issue Oct 8, 2024 · 1 comment
Assignees
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

Comments

@geoludbit
Copy link

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.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Oct 8, 2024
@bclozel bclozel transferred this issue from spring-projects/spring-boot Oct 8, 2024
@bclozel bclozel added in: web Issues in web modules (web, webmvc, webflux, websocket) theme: observability An issue related to observability and tracing labels Oct 8, 2024
@bclozel bclozel self-assigned this Oct 8, 2024
@bclozel
Copy link
Member

bclozel commented Oct 21, 2024

Thanks for the sample.
This logging happens in Tomcat, in the org.apache.catalina.core package - this means this is logged outside of the tracing scope, after the observation Servlet filter.

If you're looking for a more comprehensive tracing solution that only applies to Tomcat, you can use a Tomcat Valve to instrument your application - see micrometer-metrics/micrometer#3777 for more details on Micrometer support for this.

@bclozel bclozel closed this as not planned Won't fix, can't repro, duplicate, stale Oct 21, 2024
@bclozel bclozel added status: invalid An issue that we don't feel is valid for: external-project Needs a fix in external project and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
Projects
None yet
Development

No branches or pull requests

3 participants