Title: Support for asynchronous requests · Issue #3982 · getsentry/sentry-java · GitHub
Open Graph Title: Support for asynchronous requests · Issue #3982 · getsentry/sentry-java
X Title: Support for asynchronous requests · Issue #3982 · getsentry/sentry-java
Description: Problem Statement 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...
Open Graph Description: Problem Statement 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 ...
X Description: Problem Statement 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 ...
Opengraph URL: https://github.com/getsentry/sentry-java/issues/3982
X: @github
Domain: github.com
IPv4 address: 140.82.112.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Support for asynchronous requests","articleBody":"### Problem Statement\n\nThe [Sentry Spring Boot](https://docs.sentry.io/platforms/java/guides/spring-boot/async/) 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. \n\nHere's an example:\n\n```java\n@GetMapping\npublic Callable\u003cVoid> test() {\n var outerSpan = Sentry.getSpan();\n\n return () -> {\n var innerSpan = Sentry.getSpan();\n return null;\n };\n}\n```\n\n* `outerSpan` is always non-null, not noop and not finished, as expected.\n* Without using `SentryTaskDecorator`, the `innerSpan` is null, as expected.\n* 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.\n\nThe same applies to `Future`s, `StreamingResponseBody`, and [any other method for async processing](https://docs.spring.io/spring-framework/reference/web/webmvc/mvc-ann-async.html). I will give more examples if necessary.\n\n### Solution Brainstorm\n\nThe 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.","author":{"url":"https://github.com/aesy","@type":"Person","name":"aesy"},"datePublished":"2024-12-12T09:14:05Z","url":"https://github.com/getsentry/sentry-java/issues/3982"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:d929e5a6-ec52-c725-a6a0-f79195df6462 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D0AA:2D6F70:45A204:61E3A7:6B047097 |
| html-safe-nonce | a40c69e08d6dd9f0e123c85f9aa0a0519a3d666f7bdc92fca292a8fe894a80f3 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMEFBOjJENkY3MDo0NUEyMDQ6NjFFM0E3OjZCMDQ3MDk3IiwidmlzaXRvcl9pZCI6IjgwMTQ1MjI4NDQzMDQ0MDQ2MzIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | f199cfd5812c21ed83ab152a89e58e7706adb42092d963bf91d3869441f77f07 |
| hovercard-subject-tag | issue:2735319049 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/getsentry/sentry-java/3982/issue_layout |
| twitter:image | https://opengraph.githubassets.com/81621f3ae70917add2b76bd8458430bfd2e960a9ae78b934a90fcfc2ed8c7548/getsentry/sentry-java/issues/3982 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/81621f3ae70917add2b76bd8458430bfd2e960a9ae78b934a90fcfc2ed8c7548/getsentry/sentry-java/issues/3982 |
| og:image:alt | Problem Statement 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 ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | aesy |
| hostname | github.com |
| expected-hostname | github.com |
| None | ae8802492f12d3ba4f6b0d814054e617a2a5616b6327bf8555c10cd5b0dc2a6f |
| turbo-cache-control | no-preview |
| go-import | github.com/getsentry/sentry-java git https://github.com/getsentry/sentry-java.git |
| octolytics-dimension-user_id | 1396951 |
| octolytics-dimension-user_login | getsentry |
| octolytics-dimension-repository_id | 3368190 |
| octolytics-dimension-repository_nwo | getsentry/sentry-java |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 3368190 |
| octolytics-dimension-repository_network_root_nwo | getsentry/sentry-java |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | cfb5f24c6e01d85f70804652a5107e5cac03a161 |
| ui-target | canary-1 |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width