Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ sagp = "6.10.0"
sqlite = "2.6.2"
sqliteAlpha = "2.7.0-alpha06" # Required by Room3 3.0.0-alpha*
slf4j = "1.7.30"
spotless = "8.6.0"
spotless = "8.8.0"
springboot2 = "2.7.18"
springboot3 = "3.5.0"
springboot4 = "4.1.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,10 @@ class ActivityLifecycleIntegrationTest {

@Test
fun `Standalone app start transaction op is app start`() {
val sut =
fixture.getSut {
it.tracesSampleRate = 1.0
it.isEnableStandaloneAppStartTracing = true
}
val sut = fixture.getSut {
it.tracesSampleRate = 1.0
it.isEnableStandaloneAppStartTracing = true
}
sut.register(fixture.scopes, fixture.options)

setAppStartTime()
Expand All @@ -257,8 +256,9 @@ class ActivityLifecycleIntegrationTest {
verify(fixture.scopes, times(2)).startTransaction(any(), any<TransactionOptions>())

val contexts = fixture.capturedContexts
val appStartContext =
contexts.single { it.operation == ActivityLifecycleIntegration.STANDALONE_APP_START_OP }
val appStartContext = contexts.single {
it.operation == ActivityLifecycleIntegration.STANDALONE_APP_START_OP
}
assertEquals("App Start", appStartContext.name)
assertEquals(TransactionNameSource.COMPONENT, appStartContext.transactionNameSource)
val appStartTransaction =
Expand All @@ -278,11 +278,10 @@ class ActivityLifecycleIntegrationTest {
@Test
@Config(sdk = [Build.VERSION_CODES.VANILLA_ICE_CREAM])
fun `Standalone app start transaction carries app start reason when available`() {
val sut =
fixture.getSut {
it.tracesSampleRate = 1.0
it.isEnableStandaloneAppStartTracing = true
}
val sut = fixture.getSut {
it.tracesSampleRate = 1.0
it.isEnableStandaloneAppStartTracing = true
}
sut.register(fixture.scopes, fixture.options)

setAppStartTime()
Expand All @@ -304,11 +303,10 @@ class ActivityLifecycleIntegrationTest {

@Test
fun `Standalone app start transaction has no app start reason when unavailable`() {
val sut =
fixture.getSut {
it.tracesSampleRate = 1.0
it.isEnableStandaloneAppStartTracing = true
}
val sut = fixture.getSut {
it.tracesSampleRate = 1.0
it.isEnableStandaloneAppStartTracing = true
}
sut.register(fixture.scopes, fixture.options)

setAppStartTime()
Expand All @@ -326,11 +324,10 @@ class ActivityLifecycleIntegrationTest {
@Test
@Config(sdk = [Build.VERSION_CODES.VANILLA_ICE_CREAM])
fun `Headless standalone app start transaction carries app start reason when available`() {
val sut =
fixture.getSut {
it.tracesSampleRate = 1.0
it.isEnableStandaloneAppStartTracing = true
}
val sut = fixture.getSut {
it.tracesSampleRate = 1.0
it.isEnableStandaloneAppStartTracing = true
}
sut.register(fixture.scopes, fixture.options)
prepareHeadlessAppStart(appStartType = AppStartType.COLD)
val startInfo =
Expand All @@ -347,11 +344,10 @@ class ActivityLifecycleIntegrationTest {

@Test
fun `HeadlessAppStartListener is registered when standalone flag is on and performance enabled`() {
val sut =
fixture.getSut {
it.tracesSampleRate = 1.0
it.isEnableStandaloneAppStartTracing = true
}
val sut = fixture.getSut {
it.tracesSampleRate = 1.0
it.isEnableStandaloneAppStartTracing = true
}
sut.register(fixture.scopes, fixture.options)
prepareHeadlessAppStart(appStartType = AppStartType.UNKNOWN)

Expand Down Expand Up @@ -389,11 +385,10 @@ class ActivityLifecycleIntegrationTest {

@Test
fun `close clears HeadlessAppStartListener`() {
val sut =
fixture.getSut {
it.tracesSampleRate = 1.0
it.isEnableStandaloneAppStartTracing = true
}
val sut = fixture.getSut {
it.tracesSampleRate = 1.0
it.isEnableStandaloneAppStartTracing = true
}
sut.register(fixture.scopes, fixture.options)
sut.close()
prepareHeadlessAppStart()
Expand All @@ -405,11 +400,10 @@ class ActivityLifecycleIntegrationTest {

@Test
fun `onHeadlessAppStart creates standalone App Start transaction and stashes trace id`() {
val sut =
fixture.getSut {
it.tracesSampleRate = 1.0
it.isEnableStandaloneAppStartTracing = true
}
val sut = fixture.getSut {
it.tracesSampleRate = 1.0
it.isEnableStandaloneAppStartTracing = true
}
sut.register(fixture.scopes, fixture.options)
prepareHeadlessAppStart(appStartType = AppStartType.COLD)

Expand All @@ -436,11 +430,10 @@ class ActivityLifecycleIntegrationTest {
@Test
@Config(sdk = [Build.VERSION_CODES.M])
fun `onHeadlessAppStart creates standalone App Start transaction on API 23`() {
val sut =
fixture.getSut {
it.tracesSampleRate = 1.0
it.isEnableStandaloneAppStartTracing = true
}
val sut = fixture.getSut {
it.tracesSampleRate = 1.0
it.isEnableStandaloneAppStartTracing = true
}
sut.register(fixture.scopes, fixture.options)
prepareHeadlessSdkInitAppStart()

Expand All @@ -463,11 +456,10 @@ class ActivityLifecycleIntegrationTest {

@Test
fun `onHeadlessAppStart creates standalone App Start transaction when appStartType is WARM`() {
val sut =
fixture.getSut {
it.tracesSampleRate = 1.0
it.isEnableStandaloneAppStartTracing = true
}
val sut = fixture.getSut {
it.tracesSampleRate = 1.0
it.isEnableStandaloneAppStartTracing = true
}
sut.register(fixture.scopes, fixture.options)
prepareHeadlessAppStart(appStartType = AppStartType.WARM)

Expand All @@ -482,11 +474,10 @@ class ActivityLifecycleIntegrationTest {

@Test
fun `onHeadlessAppStart does nothing when appStartTimeSpan is incomplete`() {
val sut =
fixture.getSut {
it.tracesSampleRate = 1.0
it.isEnableStandaloneAppStartTracing = true
}
val sut = fixture.getSut {
it.tracesSampleRate = 1.0
it.isEnableStandaloneAppStartTracing = true
}
sut.register(fixture.scopes, fixture.options)
AppStartMetrics.getInstance().appStartTimeSpan.reset()
AppStartMetrics.getInstance().sdkInitTimeSpan.reset()
Expand Down Expand Up @@ -801,11 +792,10 @@ class ActivityLifecycleIntegrationTest {

@Test
fun `When Activity is destroyed, sets standalone appStartTransaction status to cancelled and finish it`() {
val sut =
fixture.getSut {
it.tracesSampleRate = 1.0
it.isEnableStandaloneAppStartTracing = true
}
val sut = fixture.getSut {
it.tracesSampleRate = 1.0
it.isEnableStandaloneAppStartTracing = true
}
sut.register(fixture.scopes, fixture.options)

setAppStartTime()
Expand Down Expand Up @@ -1177,11 +1167,10 @@ class ActivityLifecycleIntegrationTest {

@Test
fun `launcher activity emits ui load and standalone App Start sharing trace id`() {
val sut =
fixture.getSut {
it.tracesSampleRate = 1.0
it.isEnableStandaloneAppStartTracing = true
}
val sut = fixture.getSut {
it.tracesSampleRate = 1.0
it.isEnableStandaloneAppStartTracing = true
}
sut.register(fixture.scopes, fixture.options)
val firstFrameDate = SentryNanotimeDate(1499, 0)
fixture.options.dateProvider = SentryDateProvider { firstFrameDate }
Expand Down Expand Up @@ -1232,11 +1221,10 @@ class ActivityLifecycleIntegrationTest {

@Test
fun `launcher activity attaches lifecycle spans before finishing stopped standalone App Start`() {
val sut =
fixture.getSut {
it.tracesSampleRate = 1.0
it.isEnableStandaloneAppStartTracing = true
}
val sut = fixture.getSut {
it.tracesSampleRate = 1.0
it.isEnableStandaloneAppStartTracing = true
}
sut.register(fixture.scopes, fixture.options)
val appStartEndDate = SentryNanotimeDate(499, 0)
setAppStartTime(SentryNanotimeDate(1, 0), appStartEndDate)
Expand Down Expand Up @@ -1265,11 +1253,10 @@ class ActivityLifecycleIntegrationTest {
@Test
fun `activity following a headless start reuses trace id and does not emit second standalone`() {
val storedTraceId = SentryId()
val sut =
fixture.getSut {
it.tracesSampleRate = 1.0
it.isEnableStandaloneAppStartTracing = true
}
val sut = fixture.getSut {
it.tracesSampleRate = 1.0
it.isEnableStandaloneAppStartTracing = true
}
AppStartMetrics.getInstance().setAppStartTraceId(storedTraceId)
// headless start always stores the trace header alongside the trace id; the ui.load txn
// continues that trace via continueTrace, sharing the trace id.
Expand All @@ -1291,11 +1278,10 @@ class ActivityLifecycleIntegrationTest {
@Test
fun `activity within a minute of the headless start continues the same trace`() {
val storedTraceId = SentryId()
val sut =
fixture.getSut {
it.tracesSampleRate = 1.0
it.isEnableStandaloneAppStartTracing = true
}
val sut = fixture.getSut {
it.tracesSampleRate = 1.0
it.isEnableStandaloneAppStartTracing = true
}
AppStartMetrics.getInstance().setAppStartTraceId(storedTraceId)
AppStartMetrics.getInstance().appStartSentryTraceHeader =
SentryTraceHeader(storedTraceId, SpanId(), true).value
Expand All @@ -1315,11 +1301,10 @@ class ActivityLifecycleIntegrationTest {
@Test
fun `activity more than a minute after the headless start starts a fresh trace`() {
val storedTraceId = SentryId()
val sut =
fixture.getSut {
it.tracesSampleRate = 1.0
it.isEnableStandaloneAppStartTracing = true
}
val sut = fixture.getSut {
it.tracesSampleRate = 1.0
it.isEnableStandaloneAppStartTracing = true
}
AppStartMetrics.getInstance().setAppStartTraceId(storedTraceId)
AppStartMetrics.getInstance().appStartSentryTraceHeader =
SentryTraceHeader(storedTraceId, SpanId(), true).value
Expand All @@ -1341,11 +1326,10 @@ class ActivityLifecycleIntegrationTest {

@Test
fun `onHeadlessAppStart stores sentry-trace and baggage headers for continuation`() {
val sut =
fixture.getSut {
it.tracesSampleRate = 1.0
it.isEnableStandaloneAppStartTracing = true
}
val sut = fixture.getSut {
it.tracesSampleRate = 1.0
it.isEnableStandaloneAppStartTracing = true
}
sut.register(fixture.scopes, fixture.options)
prepareHeadlessAppStart(appStartType = AppStartType.COLD)

Expand All @@ -1363,11 +1347,10 @@ class ActivityLifecycleIntegrationTest {

@Test
fun `launcher activity shares standalone App Start trace and sampleRand as a sibling`() {
val sut =
fixture.getSut {
it.tracesSampleRate = 1.0
it.isEnableStandaloneAppStartTracing = true
}
val sut = fixture.getSut {
it.tracesSampleRate = 1.0
it.isEnableStandaloneAppStartTracing = true
}
sut.register(fixture.scopes, fixture.options)
setAppStartTime()
// the app-start sampling decision carries the sampleRand the whole trace should share
Expand Down Expand Up @@ -1396,11 +1379,10 @@ class ActivityLifecycleIntegrationTest {

@Test
fun `activity following a headless start shares stored trace and sampleRand as a sibling and clears headers`() {
val sut =
fixture.getSut {
it.tracesSampleRate = 1.0
it.isEnableStandaloneAppStartTracing = true
}
val sut = fixture.getSut {
it.tracesSampleRate = 1.0
it.isEnableStandaloneAppStartTracing = true
}
sut.register(fixture.scopes, fixture.options)

// 1) a headless start emits the standalone app.start and stores its trace headers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -539,13 +539,12 @@ class AndroidContinuousProfilerTest {

@Test
fun `profiler does not start when offline`() {
val profiler =
fixture.getSut {
it.connectionStatusProvider = mock { provider ->
whenever(provider.connectionStatus)
.thenReturn(IConnectionStatusProvider.ConnectionStatus.DISCONNECTED)
}
val profiler = fixture.getSut {
it.connectionStatusProvider = mock { provider ->
whenever(provider.connectionStatus)
.thenReturn(IConnectionStatusProvider.ConnectionStatus.DISCONNECTED)
}
}

// If the device is offline, the profiler should never start
profiler.startProfiler(ProfileLifecycle.MANUAL, fixture.mockTracesSampler)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,11 @@ class AndroidLoggerBatchProcessorTest {

@Test
fun `onBackground handles executor exception gracefully`() {
val sut =
fixture.getSut { options ->
val rejectingExecutor = mock<io.sentry.ISentryExecutorService>()
whenever(rejectingExecutor.submit(any())).thenThrow(RuntimeException("Rejected"))
options.executorService = rejectingExecutor
}
val sut = fixture.getSut { options ->
val rejectingExecutor = mock<io.sentry.ISentryExecutorService>()
whenever(rejectingExecutor.submit(any())).thenThrow(RuntimeException("Rejected"))
options.executorService = rejectingExecutor
}

// Should not throw
sut.onBackground()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,11 @@ class AndroidMetricsBatchProcessorTest {

@Test
fun `onBackground handles executor exception gracefully`() {
val sut =
fixture.getSut { options ->
val rejectingExecutor = mock<io.sentry.ISentryExecutorService>()
whenever(rejectingExecutor.submit(any())).thenThrow(RuntimeException("Rejected"))
options.executorService = rejectingExecutor
}
val sut = fixture.getSut { options ->
val rejectingExecutor = mock<io.sentry.ISentryExecutorService>()
whenever(rejectingExecutor.submit(any())).thenThrow(RuntimeException("Rejected"))
options.executorService = rejectingExecutor
}

// Should not throw
sut.onBackground()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,11 @@ abstract class ApplicationExitIntegrationTestBase<THint : Any> {
val hintAccessors: HintAccessors<THint>,
val addExitInfo:
ApplicationExitTestFixture<THint>.(
reason: Int?, timestamp: Long?, importance: Int?, addTrace: Boolean, addBadTrace: Boolean,
reason: Int?,
timestamp: Long?,
importance: Int?,
addTrace: Boolean,
addBadTrace: Boolean,
) -> Unit,
val flushLogPrefix: String,
)
Expand Down
Loading
Loading