-
-
Notifications
You must be signed in to change notification settings - Fork 359
perf(android): Replace RNSentryFrameDelayCollector with sentry-java getFramesDelay API #6074
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
5a75171
perf(android): Replace RNSentryFrameDelayCollector with sentry-java gโฆ
antonis ea9d0b6
Add chanfgelog
antonis 5bad294
Merge branch 'main' into feat/android-frames-delay-api
antonis 3984ffe
Update CHANGELOG for sentry-java API usage
antonis 8047e3d
Merge branch 'main' into feat/android-frames-delay-api
antonis 6b4adee
style(android): Fix java formatting for RNSentryModuleImpl
antonis af43c22
test(android): Add unit tests for fetchNativeFramesDelay
antonis 6c22bb5
fix(android): Add defensive null check on getFramesDelay result
antonis dfe56da
fix(android): Only set frameMetricsCollector when startCollection sucโฆ
antonis 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
128 changes: 0 additions & 128 deletions
128
packages/core/android/src/main/java/io/sentry/react/RNSentryFrameDelayCollector.java
This file was deleted.
Oops, something went wrong.
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
101 changes: 101 additions & 0 deletions
101
packages/core/android/src/test/java/io/sentry/react/RNSentryFramesDelayTest.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,101 @@ | ||
| package io.sentry.react; | ||
|
|
||
| import static org.mockito.ArgumentMatchers.anyInt; | ||
| import static org.mockito.ArgumentMatchers.anyLong; | ||
| import static org.mockito.ArgumentMatchers.anyString; | ||
| import static org.mockito.ArgumentMatchers.eq; | ||
| import static org.mockito.ArgumentMatchers.isNull; | ||
| import static org.mockito.Mockito.mock; | ||
| import static org.mockito.Mockito.verify; | ||
| import static org.mockito.Mockito.when; | ||
|
|
||
| import android.content.pm.PackageInfo; | ||
| import android.content.pm.PackageManager; | ||
| import com.facebook.react.bridge.Promise; | ||
| import com.facebook.react.bridge.ReactApplicationContext; | ||
| import io.sentry.android.core.SentryFramesDelayResult; | ||
| import io.sentry.android.core.internal.util.SentryFrameMetricsCollector; | ||
| import org.junit.Before; | ||
| import org.junit.Test; | ||
|
|
||
| public class RNSentryFramesDelayTest { | ||
|
|
||
| private RNSentryModuleImpl module; | ||
| private Promise promise; | ||
|
|
||
| @Before | ||
| public void setUp() throws Exception { | ||
| ReactApplicationContext reactContext = mock(ReactApplicationContext.class); | ||
| PackageManager packageManager = mock(PackageManager.class); | ||
| when(packageManager.getPackageInfo(anyString(), anyInt())).thenReturn(new PackageInfo()); | ||
| when(reactContext.getPackageManager()).thenReturn(packageManager); | ||
| when(reactContext.getPackageName()).thenReturn("com.test.app"); | ||
| module = new RNSentryModuleImpl(reactContext); | ||
| promise = mock(Promise.class); | ||
| } | ||
|
|
||
| @Test | ||
| public void resolvesNullWhenCollectorIsNull() { | ||
| module.frameMetricsCollector = null; | ||
| double now = System.currentTimeMillis() / 1e3; | ||
| module.fetchNativeFramesDelay(now - 1.0, now, promise); | ||
| verify(promise).resolve(isNull()); | ||
| } | ||
|
|
||
| @Test | ||
| public void resolvesDelayFromCollector() { | ||
| SentryFrameMetricsCollector collector = mock(SentryFrameMetricsCollector.class); | ||
| when(collector.getFramesDelay(anyLong(), anyLong())) | ||
| .thenReturn(new SentryFramesDelayResult(0.123, 2)); | ||
| module.frameMetricsCollector = collector; | ||
|
|
||
| double now = System.currentTimeMillis() / 1e3; | ||
| module.fetchNativeFramesDelay(now - 1.0, now, promise); | ||
| verify(promise).resolve(eq(0.123)); | ||
| } | ||
|
|
||
| @Test | ||
| public void resolvesNullWhenDelayIsNegative() { | ||
| SentryFrameMetricsCollector collector = mock(SentryFrameMetricsCollector.class); | ||
| when(collector.getFramesDelay(anyLong(), anyLong())) | ||
| .thenReturn(new SentryFramesDelayResult(-1, 0)); | ||
| module.frameMetricsCollector = collector; | ||
|
|
||
| double now = System.currentTimeMillis() / 1e3; | ||
| module.fetchNativeFramesDelay(now - 1.0, now, promise); | ||
| verify(promise).resolve(isNull()); | ||
| } | ||
|
|
||
| @Test | ||
| public void resolvesNullWhenResultIsNull() { | ||
| SentryFrameMetricsCollector collector = mock(SentryFrameMetricsCollector.class); | ||
| when(collector.getFramesDelay(anyLong(), anyLong())).thenReturn(null); | ||
| module.frameMetricsCollector = collector; | ||
|
|
||
| double now = System.currentTimeMillis() / 1e3; | ||
| module.fetchNativeFramesDelay(now - 1.0, now, promise); | ||
| verify(promise).resolve(isNull()); | ||
| } | ||
|
|
||
| @Test | ||
| public void resolvesNullWhenStartIsInFuture() { | ||
| SentryFrameMetricsCollector collector = mock(SentryFrameMetricsCollector.class); | ||
| module.frameMetricsCollector = collector; | ||
|
|
||
| double now = System.currentTimeMillis() / 1e3; | ||
| module.fetchNativeFramesDelay(now + 100.0, now + 200.0, promise); | ||
| verify(promise).resolve(isNull()); | ||
| } | ||
|
|
||
| @Test | ||
| public void resolvesZeroDelayWhenNoSlowFrames() { | ||
| SentryFrameMetricsCollector collector = mock(SentryFrameMetricsCollector.class); | ||
| when(collector.getFramesDelay(anyLong(), anyLong())) | ||
| .thenReturn(new SentryFramesDelayResult(0.0, 0)); | ||
| module.frameMetricsCollector = collector; | ||
|
|
||
| double now = System.currentTimeMillis() / 1e3; | ||
| module.fetchNativeFramesDelay(now - 1.0, now, promise); | ||
| verify(promise).resolve(eq(0.0)); | ||
| } | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.