Skip to content

Conversation

@aesy
Copy link
Contributor

@aesy aesy commented Dec 12, 2024

Keeps the transaction open until the response is committed.

Fixes #3982

aesy and others added 2 commits December 16, 2024 11:51
Keeps the transaction open until the response is committed.
Copy link
Member

@adinauer adinauer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, sorry for the long wait here. I just took a quick look and the way this is implemented at the moment would break distributed tracing. I'll update the PR to fix this.

Also this is still based on v7 main, I'll update to current main.

httpRequest.getHeader(SentryTraceHeader.SENTRY_TRACE_HEADER);
final @Nullable List<String> baggageHeader =
Collections.list(httpRequest.getHeaders(BaggageHeader.BAGGAGE_HEADER));
final @Nullable TransactionContext transactionContext =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change would break existing functionality. We would no longer be parsing and propagating incoming tracing information or create a new trace in case there's no incoming info. This would break distributed tracing, which allows you to track execution from e.g. an App across multiple servers.

@adinauer adinauer requested a review from lcian as a code owner February 20, 2025 11:10
@adinauer
Copy link
Member

I've updated the PR.

  • Merged in latest version of main
  • Fixed the tracing without performance problem
  • Added a config option to enable this behaviour via sentry.keep-transactions-open-for-async-responses=true for now. We can revisit at a later point whether this should become opt-out.
  • Tried adding some comments / naming method so we know how this works when coming back to the code in the future.

I'll let someone else on the team review this, since I've changed quite a bit.

You may also want to give our OpenTelemetry based SDK a try if you can't wait for this change to be released. Docs on how to setup can be found here: https://docs.sentry.io/platforms/java/guides/spring-boot/

@lcian
Copy link
Member

lcian commented Feb 20, 2025

Ooops didn't mean to approve but just to comment.
Anyway, could we add tests? @adinauer
Maybe one of the comments I highlighted above is wrong and the booleans are confusing me, but it's not immediately clear to me that this works as intended.

@adinauer adinauer requested a review from lcian February 24, 2025 15:33
Copy link
Member

@lcian lcian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@adinauer adinauer mentioned this pull request Feb 26, 2025
@adinauer adinauer merged commit f64d1f2 into getsentry:main Feb 26, 2025
33 checks passed
@adinauer
Copy link
Member

Thanks again for the PR @aesy, we've just released this as part of https://github.com/getsentry/sentry-java/releases/tag/8.3.0

@aesy
Copy link
Contributor Author

aesy commented Feb 27, 2025

That's great, thank you for the update!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for asynchronous requests

3 participants