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

Mark previous session as abnormal if an ANR (ANRv2) has happened #2621

Merged
merged 19 commits into from
Apr 4, 2023

Conversation

romtsn
Copy link
Member

@romtsn romtsn commented Mar 23, 2023

#skip-changelog

📜 Description

  • There are 3 main changes:
    • AnrV2Integration will now send events with AbnormalExit hint to mark previous session as abnormal and set the session end timestamp when the ANR event happened
    • EnvelopeCache is not responsible for finishing and packaging unfinished session into envelope. Instead, it will just save it to previous_session.json file and let others handle it
    • A new class PreviousSessionFinalizer is added, which is gonna be scheduled on a single-threaded executor (i.e. after AnrV2), which is responsible for finalizing and sending unfinished sessions from a previous app run. Unfinished sessions can also be caused by e.g. user killing the app through task manager or native crashes (not only ANRs), so this class is generalized and can handle any of the process death.

Note, that there's also a new lock introduced waitPreviousSessionFlush, which is necessary due to async nature of how we start a new session (SentryAndroid.init) and how we process ANRs/how we finish unfinished session (on a background thread). So the PreviousSessionFinalizer and AnrV2Integration will wait until the new session is started, which will, in turn, flush the unfinished session from a previous app run into previous_session.json file and release the lock.

💡 Motivation and Context

Q1 Goal

💚 How did you test it?

Manually and automated

📝 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

@github-actions
Copy link
Contributor

github-actions bot commented Mar 23, 2023

Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against 642462a

@github-actions
Copy link
Contributor

github-actions bot commented Mar 23, 2023

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 271.59 ms 348.16 ms 76.57 ms
Size 1.73 MiB 2.27 MiB 560.83 KiB

Previous results on branch: feat/anr-v2-session-abnormal

Startup times

Revision Plain With Sentry Diff
9c65254 282.94 ms 305.16 ms 22.23 ms
ccf0128 269.76 ms 345.94 ms 76.18 ms
b59af9b 293.20 ms 342.63 ms 49.43 ms
9355125 348.80 ms 440.19 ms 91.40 ms

App size

Revision Plain With Sentry Diff
9c65254 1.73 MiB 2.27 MiB 556.58 KiB
ccf0128 1.73 MiB 2.27 MiB 557.09 KiB
b59af9b 1.73 MiB 2.27 MiB 557.08 KiB
9355125 1.73 MiB 2.27 MiB 557.07 KiB

@romtsn romtsn changed the title Mark previous session as abnormal if an ANR has happened Mark previous session as abnormal if an ANRv2 has happened Mar 31, 2023
@romtsn romtsn changed the title Mark previous session as abnormal if an ANRv2 has happened Mark previous session as abnormal if an ANR (ANRv2) has happened Mar 31, 2023
@romtsn romtsn marked this pull request as ready for review March 31, 2023 21:50
@codecov
Copy link

codecov bot commented Mar 31, 2023

Codecov Report

Patch coverage: 77.41% and project coverage change: +0.74 🎉

Comparison is base (2078e71) 80.28% compared to head (642462a) 81.03%.

Additional details and impacted files
@@                Coverage Diff                @@
##             feat/anr-v2    #2621      +/-   ##
=================================================
+ Coverage          80.28%   81.03%   +0.74%     
- Complexity          3990     4354     +364     
=================================================
  Files                327      344      +17     
  Lines              15017    16085    +1068     
  Branches            1977     2166     +189     
=================================================
+ Hits               12057    13035     +978     
+ Misses              2183     2151      -32     
- Partials             777      899     +122     
Impacted Files Coverage Δ
...ry/spring/boot/SentryWebfluxAutoConfiguration.java 57.14% <0.00%> (-9.53%) ⬇️
...y/spring/jakarta/CachedBodyHttpServletRequest.java 80.00% <ø> (ø)
...y/spring/jakarta/CachedBodyServletInputStream.java 40.00% <ø> (ø)
...sentry/spring/jakarta/RequestPayloadExtractor.java 37.50% <ø> (ø)
...a/io/sentry/spring/jakarta/SentrySpringFilter.java 73.68% <ø> (ø)
...karta/SentrySpringServletContainerInitializer.java 0.00% <ø> (ø)
...ava/io/sentry/spring/jakarta/SentryUserFilter.java 93.33% <ø> (ø)
...racing/SentrySpanClientHttpRequestInterceptor.java 0.00% <0.00%> (ø)
...ebflux/SentryWebFilterWithThreadLocalAccessor.java 0.00% <0.00%> (ø)
...ntry/src/main/java/io/sentry/IOptionsObserver.java 0.00% <0.00%> (ø)
... and 96 more

... and 4 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

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

Copy link
Member

@markushi markushi left a comment

Choose a reason for hiding this comment

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

Looking good! I left a few comments, mainly for better understanding the whole mechanism.

@romtsn romtsn merged commit 6f8b473 into feat/anr-v2 Apr 4, 2023
@romtsn romtsn deleted the feat/anr-v2-session-abnormal branch April 4, 2023 15:38
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.

3 participants