You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Sentry Spring Boot documentation states that there's support for Spring MVC methods to be asynchronous using for example a Callable or StreamingResponseBody by decorating the task executor with a SentryTaskDecorator. While this will propagate the context to the new thread, it will not keep the request transaction open until it's completed, so sometime during the execution of the method, the transaction will finish and subsequent spans will be dropped.
outerSpan is always non-null, not noop and not finished, as expected.
Without using SentryTaskDecorator, the innerSpan is null, as expected.
With a SentryTaskDecorator, the innerSpan is non-null, and not noop, as expected, but it may or may not be finished - this is a race condition! Put a sleep in there and it will always be in a finished state.
The underlying issue seems to be that the SentryTracingFilter does not handle async dispatches. This can be fixed by handling DispatcherType.ASYNC and keeping the transaction open until the response is committed. I will provide a pull request for this shortly.
The text was updated successfully, but these errors were encountered:
Problem Statement
The Sentry Spring Boot documentation states that there's support for Spring MVC methods to be asynchronous using for example a
Callable
orStreamingResponseBody
by decorating the task executor with aSentryTaskDecorator
. While this will propagate the context to the new thread, it will not keep the request transaction open until it's completed, so sometime during the execution of the method, the transaction will finish and subsequent spans will be dropped.Here's an example:
outerSpan
is always non-null, not noop and not finished, as expected.SentryTaskDecorator
, theinnerSpan
is null, as expected.SentryTaskDecorator
, theinnerSpan
is non-null, and not noop, as expected, but it may or may not be finished - this is a race condition! Put a sleep in there and it will always be in a finished state.The same applies to
Future
s,StreamingResponseBody
, and any other method for async processing. I will give more examples if necessary.Solution Brainstorm
The underlying issue seems to be that the
SentryTracingFilter
does not handle async dispatches. This can be fixed by handlingDispatcherType.ASYNC
and keeping the transaction open until the response is committed. I will provide a pull request for this shortly.The text was updated successfully, but these errors were encountered: