-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use onCreate invocation to denote Activity init start time (#820)
## Goal In production, we are seeing a small minority of cases where there is a big gap between when onActivityPreCreated was invoked and when onActivityStart() was invoked. This could be a case of these being two separate activities or instances, or there are cases when the activity creation and starting stage can be paused. In order to improve the trace and diagnose what's really going on, I changed the trace to use the onCreate time rather than the preCreate time, which is how it works on Android 9 or earlier, as preCreate is not a thing on those API versions. We also explicitly log the pre-create and post-create times as attributes for further debugging if this doesn't end up addressing the problem. As well as the fix, I tweaked the implementation of the trace logging component (AppStartupTraceEmitter) so it's more streamlined, logs the name of the activity being displayed, removed the emb- prefix on attributes, and extracted the public interface into an interface so i can more easily test the StartupTracker by faking that. In additional, I added more tests to verify the startup trace being logged properly as well as the `StartupTracker` consuming lifecycle events properly. I couldn't add test to verify the render due to the limitations of Roboletric, so I've left that alone for now. I've spent way too much time on this already.... ## Testing Updated Roboletric to the latest stable version so I can test with U as well as added the modified the appropriate tests.
- Loading branch information
Showing
12 changed files
with
534 additions
and
80 deletions.
There are no files selected for viewing
This file contains 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
54 changes: 54 additions & 0 deletions
54
...dk/src/main/java/io/embrace/android/embracesdk/capture/startup/AppStartupDataCollector.kt
This file contains 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,54 @@ | ||
package io.embrace.android.embracesdk.capture.startup | ||
|
||
/** | ||
* Collects relevant information during app startup to be used to produce telemetry about the startup workflow. | ||
* | ||
* Due to differences in behaviour between platform versions and various startup scenarios, you cannot assume that these methods | ||
* will be invoked in any order or at all. Implementations need to take into account that fact when using the underlying data. | ||
*/ | ||
internal interface AppStartupDataCollector { | ||
/** | ||
* Set the time when the application object initialization was started | ||
*/ | ||
fun applicationInitStart(timestampMs: Long? = null) | ||
|
||
/** | ||
* Set the time when the application object initialization has finished | ||
*/ | ||
fun applicationInitEnd(timestampMs: Long? = null) | ||
|
||
/** | ||
* Set the time just prior to the creation of the Activity whose rendering will denote the end of the startup workflow | ||
*/ | ||
fun startupActivityPreCreated(timestampMs: Long? = null) | ||
|
||
/** | ||
* Set the time for the start of the initialization of the Activity whose rendering will denote the end of the startup workflow | ||
*/ | ||
fun startupActivityInitStart(timestampMs: Long? = null) | ||
|
||
/** | ||
* Set the time just after the creation of the Activity whose rendering will denote the end of the startup workflow | ||
*/ | ||
fun startupActivityPostCreated(timestampMs: Long? = null) | ||
|
||
/** | ||
* Set the time for the end of the initialization of the Activity whose rendering will denote the end of the startup workflow | ||
*/ | ||
fun startupActivityInitEnd(timestampMs: Long? = null) | ||
|
||
/** | ||
* Set the time for when the startup Activity begins to render as well as its name | ||
*/ | ||
fun startupActivityResumed(activityName: String, timestampMs: Long? = null) | ||
|
||
/** | ||
* Set the time for when the startup Activity has finished rendering its first frame as well as its name | ||
*/ | ||
fun firstFrameRendered(activityName: String, timestampMs: Long? = null) | ||
|
||
/** | ||
* Set an arbitrary time interval during startup that is of note | ||
*/ | ||
fun addTrackedInterval(name: String, startTimeMs: Long, endTimeMs: Long) | ||
} |
This file contains 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 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 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
Oops, something went wrong.