-
Notifications
You must be signed in to change notification settings - Fork 369
Add more performance checks #5767
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
Add more performance checks #5767
Conversation
|
📱 Scan the QR code below to install the build (arm64 only) for this PR. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #5767 +/- ##
===========================================
- Coverage 79.47% 79.47% -0.01%
===========================================
Files 2447 2453 +6
Lines 65715 65824 +109
Branches 8372 8385 +13
===========================================
+ Hits 52228 52311 +83
- Misses 10495 10515 +20
- Partials 2992 2998 +6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
e40ef51 to
1ebe4f8
Compare
1ebe4f8 to
d069e33
Compare
bmarty
left a comment
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.
Thanks! A few remarks, I'll let Ganfra do the final review
| return Intent(context, MainActivity::class.java).apply { | ||
| action = Intent.ACTION_VIEW | ||
| data = deepLinkCreator.create(sessionId, roomId, threadId, eventId).toUri() | ||
| putExtra("from_notification", true) |
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.
Maybe create a const for the String?
Also this code is also invoked by DefaultNotificationConversationService so the entry point will not be a notification. But I guess we do not want to distinguish this case for now.
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.
Handled in 5bd4c4c. This should also ensure the value is only included for notifications.
|
|
||
| override fun onBuilt() { | ||
| super.onBuilt() | ||
| analyticsColdStartWatcher.whenLoggingIn() |
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.
Note: This will be also invoked when adding an account.
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.
That's fine, this just wants to cancel the cold start time check. By the time you try to add an account, the check should already have finished or been canceled.
features/home/impl/build.gradle.kts
Outdated
|
|
||
| dependencies { | ||
| implementation(projects.appconfig) | ||
| implementation(projects.appnav) |
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.
I'd move AnalyticsColdStartWatcher to the analytics api module to avoid adding this dependency.
Also FakeAnalyticsColdStartWatcher can be moved to :analytics:test
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.
Done in bfbe01e.
| override fun whenLoggingIn() { | ||
| if (isColdStart.getAndSet(false)) { | ||
| analyticsService.removeLongRunningTransaction(ColdStartUntilCachedRoomList) | ||
| Timber.d("Canceled cold start check: user is logging in") |
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.
Neat: it seems that this is the only case where the returned value of removeLongRunningTransaction is not finished. Maybe add a parameter to removeLongRunningTransactionlike andFinish: Boolean = true? This parameter will be false here.
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.
I'd rather just return the transaction so the developers can do what they need to them, including extra parameters if needed. If we add this, we'd be returning a transaction that's already finished, so it makes no sense to return it at all since you won't be able to alter what's sent to Sentry.
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.
You make a point!
But maybe for clarity the API could be (or we could have extension on AnalyticsService like):
// Will just remove the transaction
analyticsService.cancelLongRunningTransaction(...)
// Will remove the transaction and finish it
analyticsService.finishLongRunningTransaction(...)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.
Added these helper methods in 1a79bb3.
| } | ||
| } | ||
| } | ||
| .catch { Timber.w(it.message) } |
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.
There is a warning here, maybe change to:
| .catch { Timber.w(it.message) } | |
| .catch { Timber.w(it, "Error") } |
Maybe the error above was only to debug?
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.
That's actually what I wanted, since I don't expect any actual error. I just emit the error above to cancel the flow, then use the log to just notify we've done that. I can't remember if there's a better way to cancel a hot flow from inside the flow, to be honest.
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.
OK, the error will happen when the user gives their consent later from the settings, no?
I am running the code to check this.
EDIT: so yes, it's the case. An error will occur (and will be caught) when the user opt-in for analytics in the settings.
|
I was busy with some Rust these past couple of days, but I'll continue working on this tomorrow. @ganfra having your review too before I make any changes would be nice, so I don't have to change the code twice. |
| return | ||
| } | ||
|
|
||
| val coroutineScope = CoroutineScope(sessionCoroutineScope.coroutineContext + dispatchers.computation) |
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.
Use sessionCoroutineScope.childScope?
Also I'd prefer we create the child scope in the constructor and use an atomic boolean to know if it's already started.
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.
So we'd store the jobs for the launched flows in another variable(s) so we can cancel them on stop()? I used the nullable CoroutineScope because cancelling it will also cancel all their children.
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.
Used childScope in bfbe01e.
|
Some build/quality checks are failing but those are working locally. Maybe it's a cache issue? Rebasing in case it helps with the cache issue 🤞 . |
Also add `AnalyticsService.getLongRunningTransaction` and change `AnalyticsService.stopLongRunningTransaction` to `removeLongRunningTransaction`.
We want to measure how long it takes the SDK to update the room list when the app comes back from being in background. Note we don't want to check this in cold starts, only warm ones.
…om list is displayed
…xtras` Allow `IntentProvider` to receive extras and `PendingIntentFactory` to send them.
…vice.finishLongRunningTransaction`
1a79bb3 to
faa4cb5
Compare
…creating and cancelling the same one
…actually rendered the timeline event we need to focus on
|
ganfra
left a comment
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.
Thanks, LGTM!



Content
AnalyticsService.getLongRunningTransactionand changeAnalyticsService.stopLongRunningTransactiontoremoveLongRunningTransaction.AnalyticsRoomListStateWatcherto measure how long it takes the app to receive the up to date room list after coming back from a background state.AnalyticsColdStartWatcherto measure how long it takes the app to display the cached room list from a cold start.NotificationTapOpensTimelineto check how long it takes for a notification tap to open a room.OpenRoomto check how long it takes to open a room and display the initial timeline events.Motivation and context
Add some more metrics.
Tests
Testing any of the cases added above should add those events to Sentry.
Tested devices
Checklist