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

Parse ANRv2 thread dump into threads interface #2661

Merged
merged 14 commits into from
Apr 27, 2023

Conversation

romtsn
Copy link
Member

@romtsn romtsn commented Apr 18, 2023

#skip-changelog

📜 Description

  • Parses a thread dump that we can get from AppExitInfo via getTraceInputStream(). Most of the parsing has been adapted from AOSP (with license header!), and each thread is transformed directly to SentryThread.
  • The exception for the ANR is backfilled by the stacktrace of the main thread from the thread dump
  • Adds SentryLockReason which we can infer from the thread dump and which can tell us if a thread is blocked on a lock by another thread. A SentryThread can have a dictionary/map of held locks.

💡 Motivation and Context

Part of #1796

💚 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

  • Merge it and ship it all
  • Do frontend changes accordingly

@romtsn romtsn changed the base branch from main to feat/anr-v2 April 18, 2023 11:40
@github-actions
Copy link
Contributor

github-actions bot commented Apr 18, 2023

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

Generated by 🚫 dangerJS against 537d23b

@github-actions
Copy link
Contributor

github-actions bot commented Apr 20, 2023

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 348.55 ms 405.30 ms 56.75 ms
Size 1.73 MiB 2.28 MiB 564.52 KiB

Previous results on branch: feat/anr-v2-thread-dump

Startup times

Revision Plain With Sentry Diff
5c79398 372.37 ms 400.17 ms 27.80 ms
d881681 328.72 ms 357.90 ms 29.18 ms
74b172a 341.92 ms 390.34 ms 48.42 ms
ef7c2ad 339.88 ms 396.00 ms 56.12 ms
99c12f2 318.80 ms 373.24 ms 54.44 ms
6129622 331.38 ms 381.78 ms 50.40 ms
f383e87 326.91 ms 360.36 ms 33.45 ms

App size

Revision Plain With Sentry Diff
5c79398 1.73 MiB 2.28 MiB 564.48 KiB
d881681 1.73 MiB 2.28 MiB 564.35 KiB
74b172a 1.73 MiB 2.28 MiB 564.35 KiB
ef7c2ad 1.73 MiB 2.28 MiB 564.51 KiB
99c12f2 1.73 MiB 2.28 MiB 564.44 KiB
6129622 1.73 MiB 2.28 MiB 564.48 KiB
f383e87 1.73 MiB 2.28 MiB 564.48 KiB

@romtsn romtsn marked this pull request as ready for review April 20, 2023 21:40
@romtsn romtsn changed the title Feat/anr v2 thread dump Parse ANRv2 thread dump into threads interface Apr 20, 2023
@codecov
Copy link

codecov bot commented Apr 20, 2023

Codecov Report

Patch coverage: 78.38% and project coverage change: +0.83 🎉

Comparison is base (2078e71) 80.28% compared to head (537d23b) 81.12%.

Additional details and impacted files
@@                Coverage Diff                @@
##             feat/anr-v2    #2661      +/-   ##
=================================================
+ Coverage          80.28%   81.12%   +0.83%     
- Complexity          3990     4387     +397     
=================================================
  Files                327      345      +18     
  Lines              15017    16182    +1165     
  Branches            1977     2177     +200     
=================================================
+ Hits               12057    13127    +1070     
+ Misses              2183     2155      -28     
- Partials             777      900     +123     
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 100 more

... and 6 files with indirect coverage changes

☔ 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.

LGTM! 🚀

Comment on lines 439 to 448
final String abnormalMechanism = ((AbnormalExit) hint).mechanism();
if (abnormalMechanism == null) {
return false;
}

if (abnormalMechanism.equals("anr_foreground")) {
return false;
}

return abnormalMechanism.equals("anr_background");
Copy link
Member

Choose a reason for hiding this comment

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

l: I guess you added the options for readability right? Otherwise could be simplified to:

Suggested change
final String abnormalMechanism = ((AbnormalExit) hint).mechanism();
if (abnormalMechanism == null) {
return false;
}
if (abnormalMechanism.equals("anr_foreground")) {
return false;
}
return abnormalMechanism.equals("anr_background");
final String abnormalMechanism = ((AbnormalExit) hint).mechanism();
return "anr_background".equals(abnormalMechanism);

@markushi markushi merged commit d52be74 into feat/anr-v2 Apr 27, 2023
@markushi markushi deleted the feat/anr-v2-thread-dump branch April 27, 2023 11:43
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.

None yet

3 participants