Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,16 @@ private static void setupProfiler(
if (appStartTransactionProfiler != null) {
appStartTransactionProfiler.close();
}
if (buildInfoProvider.getSdkInfoVersion() < Build.VERSION_CODES.VANILLA_ICE_CREAM) {
options
.getLogger()
.log(SentryLevel.INFO, "Continuous profiling is disabled on API levels below 35.");
if (appStartContinuousProfiler != null) {
appStartContinuousProfiler.close(true);
}
options.setContinuousProfiler(NoOpContinuousProfiler.getInstance());
return;
}
if (appStartContinuousProfiler != null) {
options.setContinuousProfiler(appStartContinuousProfiler);
// If the profiler is running, we start the performance collector too, otherwise we'd miss
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ private void createAndStartContinuousProfiler(
final @NotNull Context context,
final @NotNull SentryAppStartProfilingOptions profilingOptions,
final @NotNull AppStartMetrics appStartMetrics) {
if (buildInfoProvider.getSdkInfoVersion() < Build.VERSION_CODES.VANILLA_ICE_CREAM) {
logger.log(SentryLevel.INFO, "Continuous profiling is disabled on API levels below 35.");
return;
}

if (!profilingOptions.isContinuousProfileSampled()) {
logger.log(SentryLevel.DEBUG, "App start profiling was not sampled. It will not start.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,15 @@ class AndroidOptionsInitializerTest {
assertNull(AppStartMetrics.getInstance().appStartContinuousProfiler)
}

@Config(sdk = [Build.VERSION_CODES.UPSIDE_DOWN_CAKE])
@Test
fun `init with continuous profiling on API below 35 sets no-op continuous profiler`() {
fixture.initSut(useRealContext = true)

assertEquals(NoOpTransactionProfiler.getInstance(), fixture.sentryOptions.transactionProfiler)
assertEquals(NoOpContinuousProfiler.getInstance(), fixture.sentryOptions.continuousProfiler)
}

@Test
fun `NdkIntegration will load SentryNdk class and add to the integration list`() {
fixture.initSutWithClassLoader(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,16 @@ class SentryPerformanceProviderTest {
assertNull(AppStartMetrics.getInstance().appStartContinuousProfiler)
}

@Test
fun `when sdk is below api 35, continuous profiler is not started`() {
fixture.getSut(sdkVersion = Build.VERSION_CODES.UPSIDE_DOWN_CAKE) { config ->
writeConfig(config, profilingEnabled = false, continuousProfilingEnabled = true)
}
assertNull(AppStartMetrics.getInstance().appStartContinuousProfiler)
verify(fixture.logger)
.log(eq(SentryLevel.INFO), eq("Continuous profiling is disabled on API levels below 35."))
}

@Test
fun `when provider is closed, continuous profiler is stopped`() {
val provider = fixture.getSut { config -> writeConfig(config, profilingEnabled = false) }
Expand Down
Loading