Try fixing performance metrics (#6046)
We've detected outliers in the `Up-to-date room list` and `Open a room` transactions in Sentry. This commit tries to make sure we're starting/stopping the long running transactions when needed.
This commit is contained in:
parent
00d318ea0b
commit
7d731e192a
4 changed files with 20 additions and 6 deletions
|
|
@ -46,13 +46,17 @@ class DefaultAnalyticsRoomListStateWatcher(
|
|||
return
|
||||
}
|
||||
|
||||
val longRunningTransaction = AnalyticsLongRunningTransaction.CatchUp
|
||||
|
||||
appNavigationStateService.appNavigationState
|
||||
.map { it.isInForeground }
|
||||
.distinctUntilChanged()
|
||||
.withPreviousValue()
|
||||
.onEach { (wasInForeground, isInForeground) ->
|
||||
if (isInForeground && roomListService.state.value != RoomListService.State.Running) {
|
||||
analyticsService.startLongRunningTransaction(AnalyticsLongRunningTransaction.CatchUp)
|
||||
analyticsService.startLongRunningTransaction(longRunningTransaction)
|
||||
} else if (!isInForeground) {
|
||||
analyticsService.removeLongRunningTransaction(longRunningTransaction)
|
||||
}
|
||||
|
||||
if (wasInForeground == false && isInForeground) {
|
||||
|
|
@ -64,7 +68,7 @@ class DefaultAnalyticsRoomListStateWatcher(
|
|||
roomListService.state
|
||||
.onEach { state ->
|
||||
if (state == RoomListService.State.Running && isWarmState.get()) {
|
||||
analyticsService.finishLongRunningTransaction(AnalyticsLongRunningTransaction.CatchUp)
|
||||
analyticsService.finishLongRunningTransaction(longRunningTransaction)
|
||||
}
|
||||
}
|
||||
.launchIn(coroutineScope)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue