Add some performance metrics for Sentry (#5760)

- Add `AnalyticsService.startTransaction(...)` to start a logging transaction that can be uploaded to Sentry if the user enabled the analytics upload.
- Add `AnalyticsTransaction` wrapper to abstract the Sentry ones.
- Added several helper methods to improve the UX around these transactions.
- Then measure:
  - Time until the first sync, and how it ended.
  - Time until the first rooms are displayed.
  - Time to load a room or a preview.
  - Time to load a timeline.
This commit is contained in:
Jorge Martin Espinosa 2025-11-19 12:42:55 +01:00 committed by GitHub
parent c8604c262a
commit f78c80803b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
25 changed files with 245 additions and 41 deletions

View file

@ -20,4 +20,6 @@ interface AnalyticsProvider : AnalyticsTracker, ErrorTracker {
fun init()
fun stop()
fun startTransaction(name: String, operation: String? = null): AnalyticsTransaction?
}

View file

@ -0,0 +1,25 @@
/*
* Copyright (c) 2025 Element Creations Ltd.
*
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
* Please see LICENSE files in the repository root for full details.
*/
package io.element.android.services.analyticsproviders.api
interface AnalyticsTransaction {
fun startChild(operation: String, description: String? = null): AnalyticsTransaction
fun setData(key: String, value: Any)
fun isFinished(): Boolean
fun finish()
}
inline fun <T> AnalyticsTransaction.recordChildTransaction(operation: String, description: String? = null, block: (AnalyticsTransaction) -> T): T {
val child = startChild(operation, description)
try {
val result = block(child)
return result
} finally {
child.finish()
}
}