Skip to content

Commit 3476145

Browse files
committed
Merge branch 'feat/app-start-extension-materialize' into feat/app-start-extension-api
# Conflicts: # sentry-android-core/src/main/java/io/sentry/android/core/ActivityLifecycleIntegration.java
2 parents 0c27a47 + c2cdb14 commit 3476145

3 files changed

Lines changed: 10 additions & 21 deletions

File tree

sentry-android-core/src/main/java/io/sentry/android/core/ActivityLifecycleIntegration.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -265,10 +265,8 @@ private void startTracing(final @NotNull Activity activity) {
265265
transactionOptions.setAppStartTransaction(appStartSamplingDecision != null);
266266
setSpanOrigin(transactionOptions);
267267

268-
// An extend-app-start transaction (Sentry.extendAppStart) is already open. Reuse its trace
269-
// for this ui.load instead of creating a second app.start. It also stores an app-start
270-
// trace id, so the headless-start check below is guarded with !extensionActive to avoid
271-
// mistaking it for a finished headless start.
268+
// Guards the headless-start check below with !extensionActive so the eager extension's
269+
// stored trace id isn't mistaken for a finished headless start.
272270
final boolean extensionActive =
273271
AppStartMetrics.getInstance().getAppStartExtension().isActive();
274272

@@ -279,8 +277,6 @@ private void startTracing(final @NotNull Activity activity) {
279277

280278
final boolean isAppStart =
281279
!(firstActivityCreated || appStartTime == null || coldStart == null);
282-
// Foreground starts create app.start first; ui.load then shares its trace. When the app
283-
// start is being extended, the eager app.start txn already exists, so we continue it.
284280
final boolean createStandaloneAppStart =
285281
isAppStart
286282
&& options.isEnableStandaloneAppStartTracing()
@@ -326,9 +322,8 @@ private void startTracing(final @NotNull Activity activity) {
326322
}
327323

328324
if (extensionActive && isAppStart) {
329-
// Attach only the launch activity's screen so a later activity can't overwrite it.
330-
// Without
331-
// a screen the processor would classify the eager app.start as a headless start.
325+
// Only the launch activity sets the screen, so a later activity can't overwrite it. A
326+
// screen also keeps the processor from classifying the eager app.start as headless.
332327
AppStartMetrics.getInstance()
333328
.getAppStartExtension()
334329
.setData(APP_START_SCREEN_DATA, activityName);

sentry-android-core/src/main/java/io/sentry/android/core/AppStartExtension.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,7 @@ public void finishTransaction(final @NotNull SentryDate endTimestamp) {
134134
try (final @NotNull ISentryLifecycleToken ignored = lock.acquire()) {
135135
final @Nullable ITransaction transaction = extendedTransaction;
136136
if (transaction != null && !transaction.isFinished()) {
137-
// If the extended span already finished after endTimestamp, end the transaction there so it
138-
// contains the extended span and its duration matches the reported app start vital. When
139-
// the
140-
// span is still open, waitForChildren keeps the transaction open until it finishes.
137+
// End at the extended span's finish if it ran past endTimestamp, so the txn covers it.
141138
final @Nullable ISpan span = extendedSpan;
142139
final @Nullable SentryDate spanEnd = span == null ? null : span.getFinishDate();
143140
final @NotNull SentryDate end =

sentry-android-core/src/main/java/io/sentry/android/core/PerformanceAndroidEventProcessor.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,25 +106,22 @@ public SentryEvent process(@NotNull SentryEvent event, @NotNull Hint hint) {
106106
final long naturalDurationMs = appStartTimeSpan.getDurationMs();
107107

108108
final long appStartUpDurationMs;
109-
// Whether the app start is ready to be finalized (spans attached, marked sent). When not
110-
// ready (duration 0 on a non-extended start), we leave it for a later transaction to
111-
// retry.
109+
// Not ready (duration 0 on a non-extended start) leaves it for a later transaction.
112110
final boolean appStartReady;
113111
final @NotNull AppStartExtension extension = appStartMetrics.getAppStartExtension();
114112
if (extension.isExtended()) {
115113
final @Nullable SentryDate extendedEnd = extension.getExtendedEndTime();
116114
if (extendedEnd != null && appStartTimeSpan.hasStarted()) {
117-
// The user finished the extension: measure from process start to the extended end,
118-
// but never report shorter than the natural first-frame duration.
115+
// Measure to the extended end, but never shorter than the natural first-frame
116+
// duration.
119117
final long extendedDurationMs =
120118
TimeUnit.NANOSECONDS.toMillis(extendedEnd.nanoTimestamp())
121119
- appStartTimeSpan.getStartTimestampMs();
122120
appStartUpDurationMs = Math.max(naturalDurationMs, extendedDurationMs);
123121
appStartReady = appStartUpDurationMs != 0;
124122
} else {
125-
// The extension hit the deadline (DEADLINE_EXCEEDED -> null) or there is no valid
126-
// start: suppress the measurement so we never emit an artificially inflated value,
127-
// but still finalize the app start spans.
123+
// Deadline (null) or no valid start: suppress the measurement to avoid an inflated
124+
// value, but still finalize the spans.
128125
appStartUpDurationMs = 0;
129126
appStartReady = appStartTimeSpan.hasStarted();
130127
}

0 commit comments

Comments
 (0)