Skip to content

Commit 33a6aa0

Browse files
buenaflorclaude
andcommitted
refactor(extend-app-start): Rename isAppStartWindowOpen to canExtendAppStart
The predicate has a single consumer — the extend gate in AppStartExtension — so name it for that intent. Also drop the self-evident max-end comment in finishTransaction. Regenerated apiDump. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent dc76d9a commit 33a6aa0

5 files changed

Lines changed: 17 additions & 18 deletions

File tree

sentry-android-core/api/sentry-android-core.api

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,7 @@ public class io/sentry/android/core/performance/AppStartMetrics : io/sentry/andr
761761
public static final field staticLock Lio/sentry/util/AutoClosableReentrantLock;
762762
public fun <init> ()V
763763
public fun addActivityLifecycleTimeSpans (Lio/sentry/android/core/performance/ActivityLifecycleTimeSpan;)V
764+
public fun canExtendAppStart ()Z
764765
public fun clear ()V
765766
public fun createProcessInitSpan ()Lio/sentry/android/core/performance/TimeSpan;
766767
public fun getActivityLifecycleTimeSpans ()Ljava/util/List;
@@ -783,7 +784,6 @@ public class io/sentry/android/core/performance/AppStartMetrics : io/sentry/andr
783784
public static fun getInstance ()Lio/sentry/android/core/performance/AppStartMetrics;
784785
public fun getSdkInitTimeSpan ()Lio/sentry/android/core/performance/TimeSpan;
785786
public fun isAppLaunchedInForeground ()Z
786-
public fun isAppStartWindowOpen ()Z
787787
public fun onActivityCreated (Landroid/app/Activity;Landroid/os/Bundle;)V
788788
public fun onActivityDestroyed (Landroid/app/Activity;)V
789789
public fun onActivityPaused (Landroid/app/Activity;)V

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public void extendAppStart() {
6060
.log(SentryLevel.WARNING, "App start is already being extended.");
6161
return;
6262
}
63-
if (!metrics.isAppStartWindowOpen()) {
63+
if (!metrics.canExtendAppStart()) {
6464
Sentry.getCurrentScopes()
6565
.getOptions()
6666
.getLogger()
@@ -112,7 +112,6 @@ public void finishTransaction(final @NotNull SentryDate endTimestamp) {
112112
try (final @NotNull ISentryLifecycleToken ignored = lock.acquire()) {
113113
final @Nullable ITransaction transaction = extendedTransaction;
114114
if (transaction != null && !transaction.isFinished()) {
115-
// End at the extended span's finish if it ran past endTimestamp, so the txn covers it.
116115
final @Nullable ISpan span = extendedSpan;
117116
final @Nullable SentryDate spanEnd = span == null ? null : span.getFinishDate();
118117
final @NotNull SentryDate end =

sentry-android-core/src/main/java/io/sentry/android/core/performance/AppStartMetrics.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -344,11 +344,11 @@ public long getClassLoadedUptimeMs() {
344344
}
345345

346346
/**
347-
* Whether the app start window is still open, i.e. an app start can be extended: measurements
348-
* haven't been sent yet, no activity has been created, and the first frame hasn't been drawn. The
349-
* foreground check is ignored so headless app starts (broadcast/service) can also be extended.
347+
* Whether the app start can still be extended: measurements haven't been sent yet, no activity
348+
* has been created, and the first frame hasn't been drawn. The foreground check is ignored so
349+
* headless app starts (broadcast/service) can also be extended.
350350
*/
351-
public boolean isAppStartWindowOpen() {
351+
public boolean canExtendAppStart() {
352352
return shouldSendStartMeasurements(true)
353353
&& activeActivitiesCounter.get() == 0
354354
&& !firstDrawDone.get();

sentry-android-core/src/test/java/io/sentry/android/core/AppStartExtensionTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class AppStartExtensionTest {
3131
private val metrics = mock<AppStartMetrics>()
3232

3333
private fun extension(windowOpen: Boolean = true): AppStartExtension {
34-
whenever(metrics.isAppStartWindowOpen).thenReturn(windowOpen)
34+
whenever(metrics.canExtendAppStart()).thenReturn(windowOpen)
3535
return AppStartExtension(metrics)
3636
}
3737

sentry-android-core/src/test/java/io/sentry/android/core/performance/AppStartMetricsTest.kt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,36 +1027,36 @@ class AppStartMetricsTest {
10271027
}
10281028

10291029
@Test
1030-
fun `isAppStartWindowOpen is true on a fresh foreground start`() {
1031-
assertTrue(AppStartMetrics.getInstance().isAppStartWindowOpen)
1030+
fun `canExtendAppStart is true on a fresh foreground start`() {
1031+
assertTrue(AppStartMetrics.getInstance().canExtendAppStart())
10321032
}
10331033

10341034
@Test
1035-
fun `isAppStartWindowOpen is true for a headless (non-foreground) start`() {
1035+
fun `canExtendAppStart is true for a headless (non-foreground) start`() {
10361036
val metrics = AppStartMetrics.getInstance()
10371037
metrics.isAppLaunchedInForeground = false
1038-
assertTrue(metrics.isAppStartWindowOpen)
1038+
assertTrue(metrics.canExtendAppStart())
10391039
}
10401040

10411041
@Test
1042-
fun `isAppStartWindowOpen is false once an activity was created`() {
1042+
fun `canExtendAppStart is false once an activity was created`() {
10431043
val metrics = AppStartMetrics.getInstance()
10441044
metrics.onActivityCreated(mock(), null)
1045-
assertFalse(metrics.isAppStartWindowOpen)
1045+
assertFalse(metrics.canExtendAppStart())
10461046
}
10471047

10481048
@Test
1049-
fun `isAppStartWindowOpen is false once the first frame was drawn`() {
1049+
fun `canExtendAppStart is false once the first frame was drawn`() {
10501050
val metrics = AppStartMetrics.getInstance()
10511051
metrics.onFirstFrameDrawn()
1052-
assertFalse(metrics.isAppStartWindowOpen)
1052+
assertFalse(metrics.canExtendAppStart())
10531053
}
10541054

10551055
@Test
1056-
fun `isAppStartWindowOpen is false once start measurements were sent`() {
1056+
fun `canExtendAppStart is false once start measurements were sent`() {
10571057
val metrics = AppStartMetrics.getInstance()
10581058
metrics.onAppStartSpansSent()
1059-
assertFalse(metrics.isAppStartWindowOpen)
1059+
assertFalse(metrics.canExtendAppStart())
10601060
}
10611061

10621062
/** Drives the singleton's eager extension into the active state via the listener path. */

0 commit comments

Comments
 (0)