Repository navigation
ref(anr): [Non-Fatal ANR 4] Run AnrProfilingIntegration on the HangManager #6725
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
Open
markushi
wants to merge
24
commits into
markushi/feat/non-fatal-anr-3-thread-sample-collector
from
markushi/feat/non-fatal-anr-4-wire-recorder
+671
−541
Open
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
6771b09
ref(anr): Run AnrProfilingIntegration on the HangRecorder
markushi e5e6734
chore(anr): Merge non-fatal-anr-3 into non-fatal-anr-4
markushi 71602da
fix(anr): Draw the ANR profiling sample rate for each hang
markushi 294e5fd
chore(anr): Merge non-fatal-anr-3 into non-fatal-anr-4
markushi bc54156
feat(anr): Skip unsampled hangs in AnrProfilingIntegration
markushi e65edb7
chore(anr): Merge non-fatal-anr-3 into non-fatal-anr-4
markushi 6cf5bcc
ref(anr): Adapt AnrProfilingIntegration to nullable recording requests
markushi fff8376
chore(anr): Merge non-fatal-anr-3 into non-fatal-anr-4
markushi 13beb44
chore(anr): Merge non-fatal-anr-3 into non-fatal-anr-4
markushi d728781
ref(anr): Adapt to the renamed hang types
markushi 3ea4af7
chore(anr): Merge non-fatal-anr-3 into non-fatal-anr-4
markushi bfa05d2
chore(anr): Merge non-fatal-anr-3 into non-fatal-anr-4
markushi f5a1da8
chore(anr): Merge non-fatal-anr-3 into non-fatal-anr-4
markushi de234fa
ref(anr): Adapt to the metronome time
markushi bbcb524
chore(anr): Merge non-fatal-anr-3 into non-fatal-anr-4
markushi e8ddedb
ref(anr): Remove the options close hook
markushi b9cf6b7
chore(anr): Merge non-fatal-anr-3 into non-fatal-anr-4
markushi b4059a5
chore(anr): Merge non-fatal-anr-3 into non-fatal-anr-4
markushi 7ab7095
chore(anr): Merge non-fatal-anr-3 into non-fatal-anr-4
markushi cd503ee
chore(anr): Merge non-fatal-anr-3 into non-fatal-anr-4
markushi 31da956
chore(anr): Merge non-fatal-anr-3 into non-fatal-anr-4
markushi 749452e
chore(anr): Merge non-fatal-anr-3 into non-fatal-anr-4
markushi 518640f
chore(anr): Merge non-fatal-anr-3 into non-fatal-anr-4
markushi 5ac8168
ref(anr): Adapt to the hang sample time
markushi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
sentry-android-core/src/main/java/io/sentry/android/core/anr/AnrProfileStore.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| package io.sentry.android.core.anr; | ||
|
|
||
| import io.sentry.SentryOptions; | ||
| import io.sentry.android.core.hang.HangSampleStore; | ||
| import java.io.File; | ||
| import java.io.IOException; | ||
| import org.jetbrains.annotations.ApiStatus; | ||
| import org.jetbrains.annotations.NotNull; | ||
| import org.jetbrains.annotations.Nullable; | ||
|
|
||
| /** | ||
| * Writes the main-thread samples of a hang to the ANR profile file, which the fatal ANR path reads | ||
| * at the next app start. Opens the file at the first write. Does nothing without a {@link | ||
| * SentryOptions#getCacheDirPath()}. | ||
| */ | ||
| @ApiStatus.Internal | ||
| public final class AnrProfileStore implements HangSampleStore<AnrStackTrace> { | ||
|
|
||
| private final @NotNull SentryOptions options; | ||
| private @Nullable AnrProfileManager profileManager; | ||
|
|
||
| public AnrProfileStore(final @NotNull SentryOptions options) { | ||
| this.options = options; | ||
| } | ||
|
|
||
| @Override | ||
| public void clear() throws IOException { | ||
| final @Nullable AnrProfileManager manager = openProfileManager(); | ||
| if (manager != null) { | ||
| manager.clear(); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public void add(final @NotNull AnrStackTrace sample) throws IOException { | ||
| final @Nullable AnrProfileManager manager = openProfileManager(); | ||
| if (manager != null) { | ||
| manager.add(sample); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public void close() throws IOException { | ||
| final @Nullable AnrProfileManager manager = profileManager; | ||
| profileManager = null; | ||
| if (manager != null) { | ||
| manager.close(); | ||
| } | ||
| } | ||
|
|
||
| private @Nullable AnrProfileManager openProfileManager() { | ||
| if (profileManager == null) { | ||
| final @Nullable String cacheDirPath = options.getCacheDirPath(); | ||
| if (cacheDirPath != null) { | ||
| profileManager = | ||
| new AnrProfileManager( | ||
| options, AnrProfileRotationHelper.getFileForRecording(new File(cacheDirPath))); | ||
| } | ||
| } | ||
| return profileManager; | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah yeah that makes sense. in that case that changes the decision we made to only have a single clock that counts time during deep sleep. we should probably add a clock that doesn't count time spent during sleep and use it here. feel free to create that abstraction and name it as you see fit.
the other issue here too is that calling static methods like this means less testability.