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

Finish WebFlux transaction before popping scope #2724

Merged
merged 4 commits into from
May 30, 2023

Conversation

adinauer
Copy link
Member

@adinauer adinauer commented May 22, 2023

📜 Description

Merge SentryWebTracingFilter into SentryWebFilter to avoid ordering problems with popScope and transaction.finish.

💡 Motivation and Context

Fixes #2700

💚 How did you test it?

📝 Checklist

  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

🔮 Next steps

…roblems with popScope and transaction.finish
@github-actions
Copy link
Contributor

github-actions bot commented May 22, 2023

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 335.54 ms 342.43 ms 6.89 ms
Size 1.72 MiB 2.28 MiB 570.67 KiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
46b1782 387.72 ms 458.74 ms 71.02 ms
1707044 338.80 ms 384.79 ms 46.00 ms

App size

Revision Plain With Sentry Diff
46b1782 1.72 MiB 2.28 MiB 570.44 KiB
1707044 1.72 MiB 2.28 MiB 570.44 KiB

Previous results on branch: fix/finish-webflux-transaction-before-scope-pop

Startup times

Revision Plain With Sentry Diff
cc386a9 339.47 ms 460.14 ms 120.67 ms
1ba2a69 304.45 ms 353.29 ms 48.84 ms

App size

Revision Plain With Sentry Diff
cc386a9 1.72 MiB 2.28 MiB 570.44 KiB
1ba2a69 1.72 MiB 2.28 MiB 570.44 KiB

@codecov
Copy link

codecov bot commented May 22, 2023

Codecov Report

Patch coverage: 78.04% and project coverage change: -0.02 ⚠️

Comparison is base (5041902) 81.13% compared to head (d832b5b) 81.11%.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #2724      +/-   ##
============================================
- Coverage     81.13%   81.11%   -0.02%     
- Complexity     4449     4451       +2     
============================================
  Files           345      343       -2     
  Lines         16402    16402              
  Branches       2226     2227       +1     
============================================
- Hits          13307    13304       -3     
- Misses         2168     2169       +1     
- Partials        927      929       +2     
Impacted Files Coverage Δ
...g/boot/jakarta/SentryWebfluxAutoConfiguration.java 85.71% <ø> (+5.71%) ⬆️
...ry/spring/boot/SentryWebfluxAutoConfiguration.java 66.66% <ø> (+9.52%) ⬆️
...ebflux/SentryWebFilterWithThreadLocalAccessor.java 0.00% <0.00%> (ø)
...java/io/sentry/spring/webflux/SentryWebFilter.java 85.33% <80.00%> (-10.83%) ⬇️
...pring/jakarta/webflux/AbstractSentryWebFilter.java 83.82% <82.53%> (-10.63%) ⬇️
...sentry/spring/jakarta/webflux/SentryWebFilter.java 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Collaborator

@lbloder lbloder left a comment

Choose a reason for hiding this comment

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

Besides the questions about getting the Hub in SentryWebFilterWithThreadLocalAccessor, LGTM

__ ->
doFinally(
serverWebExchange,
Sentry.getCurrentHub(),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does Sentry.getCurrentHub() work correctly in this filter method? ReactorUtils.withSentryNewMainHubClone does not set the current hub, so shouldn't we get the hub from the context?
Or is this somehow handled by reactor behind the scenes?

Copy link
Member Author

Choose a reason for hiding this comment

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

ThreadLocal is set via ThreadLocalAccessor and propagated via reactor context.

Copy link
Member Author

Choose a reason for hiding this comment

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

Just tested again with debugger, works as expected (i.e. uses the correct hub).

serverWebExchange,
Sentry.getCurrentHub(),
transactionContainer.transaction))
.doOnError(e -> doOnError(transactionContainer.transaction, e))
.doFirst(
() -> {
doFirst(serverWebExchange, Sentry.getCurrentHub());
Copy link
Collaborator

Choose a reason for hiding this comment

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

See comment about Sentry.getCurrentHub()

Copy link
Member Author

Choose a reason for hiding this comment

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

same as above

.doFirst(
() -> {
doFirst(serverWebExchange, Sentry.getCurrentHub());
transactionContainer.transaction =
maybeStartTransaction(Sentry.getCurrentHub(), serverWebExchange.getRequest());
Copy link
Collaborator

Choose a reason for hiding this comment

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

See comment about Sentry.getCurrentHub()

Copy link
Member Author

Choose a reason for hiding this comment

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

same as above

@adinauer adinauer marked this pull request as ready for review May 26, 2023 09:32
@adinauer adinauer merged commit a62c875 into main May 30, 2023
@adinauer adinauer deleted the fix/finish-webflux-transaction-before-scope-pop branch May 30, 2023 04:53
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.

WebFlux pops scope before finishing transaction
3 participants