opentelemetry-java-instrumentation: Spans are marked as error though the exceptions are handled by @ControllerAdvice

Describe the bug I have a service that uses @ControllerAdvice by Spring Boot in order to handle exceptions globally and return the expected Problem response.

When the request is processed like processor.processRequest(request) throws Exception the processRequest method might throw an exception so that the ExceptionHandler is taking care of returning the required response.

processRequest it annotated with @WithSpan as we set custom attributes there. When an Exception is thrown, the Span is marked as error: true, though it shouldn’t as the ExceptionHandler is setting status code 400 in the response.

What did you expect to see?

I would have expected to see a regular span with error: false.

What did you see instead?

span with error: true.

What version are you using?

v1.15.0-alpha

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 19 (19 by maintainers)

Most upvoted comments

Hey @trask @trask is there some estimation on when open-telemetry/opentelemetry-java-contrib#759 could be released?

it was planned for the current release 2 days ago - but missed. I think it’ll go in the release one month from now on.

Just thought a bit more, even with exception.escaped I probably could already identify and filter those traces in order not to consider them for SLO measurements.

oh ya, I understand what you want now.

seems very related to this discussion: https://github.com/open-telemetry/opentelemetry-specification/issues/1008

@mateuszrzeszutek @laurit this is an interesting topic. it’s not entirely clear to me that we should capture exceptions when there is a non-remote parent span.

Let me see if I can create something in the next days.