-
Notifications
You must be signed in to change notification settings - Fork 20
Use the draw complete time for missing activity init timestamps #2121
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -272,15 +272,30 @@ internal class AppStartupTraceEmitter( | |
| val startupService = startupServiceProvider() ?: return | ||
| val sdkInitEndMs = startupService.getSdkInitEndMs() | ||
| if (sdkInitEndMs != null) { | ||
| appStartupRootSpan.get()?.let { startupTrace -> | ||
| recordTtid( | ||
| val startupTrace = appStartupRootSpan.get() | ||
| if (startupTrace != null) { | ||
| val uiLoadedMs = if (trackRender) { | ||
| firstFrameRenderedMs | ||
| } else { | ||
| startupActivityResumedMs | ||
| } | ||
| val activityInitStartMs = cappedBy( | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is really to deal with the activityInit end event being missing, which is fired on onStarted() fires. I am not sure if the init start event will ever be missing - for the Activity onCreate() callback to be processed after the draw, but I am handling this case just in case. After this is released, we can detect whether we have zero-duration child spans for activity init to see if it actually happens. |
||
| value = startupActivityPreCreatedMs ?: startupActivityInitStartMs, | ||
| ceiling = uiLoadedMs | ||
| ) | ||
| val activityInitEndMs = cappedBy( | ||
| value = startupActivityInitEndMs, | ||
| ceiling = uiLoadedMs | ||
| ) | ||
|
|
||
| recordTrace( | ||
| applicationInitEndMs = if (recordColdStart) applicationInitEndMs else null, | ||
| sdkInitStartMs = if (recordColdStart) startupService.getSdkInitStartMs() else null, | ||
| sdkInitEndMs = if (recordColdStart) sdkInitEndMs else null, | ||
| firstActivityInitMs = firstActivityInitStartMs, | ||
| activityInitStartMs = startupActivityPreCreatedMs ?: startupActivityInitStartMs, | ||
| activityInitEndMs = startupActivityInitEndMs, | ||
| uiLoadedMs = if (trackRender) firstFrameRenderedMs else startupActivityResumedMs, | ||
| activityInitStartMs = activityInitStartMs, | ||
| activityInitEndMs = activityInitEndMs, | ||
| uiLoadedMs = uiLoadedMs, | ||
| traceEndTimeMs = traceEndTimeMs, | ||
| completed = completed, | ||
| ) | ||
|
|
@@ -289,6 +304,17 @@ internal class AppStartupTraceEmitter( | |
| } | ||
| } | ||
|
|
||
| /** | ||
| * Limit a value based on some ceiling if it is defined. | ||
| * That is, return [ceiling] if it is non-null and less than [value]. | ||
| */ | ||
| private fun cappedBy(value: Long?, ceiling: Long?) = | ||
| if (ceiling != null && (value == null || value > ceiling)) { | ||
| ceiling | ||
| } else { | ||
| value | ||
| } | ||
|
|
||
| private fun recordAdditionalIntervals(startupTrace: EmbraceSpan) { | ||
| do { | ||
| additionalTrackedIntervals.poll()?.let { trackedInterval -> | ||
|
|
@@ -307,7 +333,7 @@ internal class AppStartupTraceEmitter( | |
| } | ||
|
|
||
| @Suppress("CyclomaticComplexMethod", "ComplexMethod") | ||
| private fun recordTtid( | ||
| private fun recordTrace( | ||
| applicationInitEndMs: Long?, | ||
| sdkInitStartMs: Long?, | ||
| sdkInitEndMs: Long?, | ||
|
|
||
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.
This is the main change. Everything else is renaming the callback method to be more appropriate