Skip to content

Commit

Permalink
Merge b1f59eb into c34791a
Browse files Browse the repository at this point in the history
  • Loading branch information
romtsn authored Feb 22, 2024
2 parents c34791a + b1f59eb commit b0eb9b4
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## Unreleased

### Features

- Add `enableScopePersistence` option to disable `PersistingScopeObserver` used for ANR reporting which may increase performance overhead. Defaults to `true` ([#3218](https://github.com/getsentry/sentry-java/pull/3218))
- When disabled, the SDK will not enrich ANRv2 events with scope data (e.g. breadcrumbs, user, tags, etc.)

### Fixes

- Fix old profiles deletion on SDK init ([#3216](https://github.com/getsentry/sentry-java/pull/3216))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,9 @@ static void initializeIntegrationsAndProcessors(
options.setTransactionPerformanceCollector(new DefaultTransactionPerformanceCollector(options));

if (options.getCacheDirPath() != null) {
options.addScopeObserver(new PersistingScopeObserver(options));
if (options.isEnableScopePersistence()) {
options.addScopeObserver(new PersistingScopeObserver(options));
}
options.addOptionsObserver(new PersistingOptionsObserver(options));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -653,4 +653,11 @@ class AndroidOptionsInitializerTest {
fixture.sentryOptions.integrations.firstOrNull { it is AnrIntegration }
assertNull(anrv1Integration)
}

@Test
fun `PersistingScopeObserver is not set to options, if scope persistence is disabled`() {
fixture.initSut(configureOptions = { isEnableScopePersistence = false })

assertTrue { fixture.sentryOptions.scopeObservers.none { it is PersistingScopeObserver } }
}
}
2 changes: 2 additions & 0 deletions sentry/api/sentry.api
Original file line number Diff line number Diff line change
Expand Up @@ -2244,6 +2244,7 @@ public class io/sentry/SentryOptions {
public fun isEnableDeduplication ()Z
public fun isEnableExternalConfiguration ()Z
public fun isEnablePrettySerializationOutput ()Z
public fun isEnableScopePersistence ()Z
public fun isEnableShutdownHook ()Z
public fun isEnableSpotlight ()Z
public fun isEnableTimeToFullDisplayTracing ()Z
Expand Down Expand Up @@ -2284,6 +2285,7 @@ public class io/sentry/SentryOptions {
public fun setEnableDeduplication (Z)V
public fun setEnableExternalConfiguration (Z)V
public fun setEnablePrettySerializationOutput (Z)V
public fun setEnableScopePersistence (Z)V
public fun setEnableShutdownHook (Z)V
public fun setEnableSpotlight (Z)V
public fun setEnableTimeToFullDisplayTracing (Z)V
Expand Down
11 changes: 11 additions & 0 deletions sentry/src/main/java/io/sentry/SentryOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,9 @@ public class SentryOptions {

private @Nullable String spotlightConnectionUrl;

/** Whether to enable scope persistence so the scope values are preserved if the process dies */
private boolean enableScopePersistence = true;

/** Contains a list of monitor slugs for which check-ins should not be sent. */
@ApiStatus.Experimental private @Nullable List<String> ignoredCheckIns = null;

Expand Down Expand Up @@ -2313,6 +2316,14 @@ public void setEnableSpotlight(final boolean enableSpotlight) {
this.enableSpotlight = enableSpotlight;
}

public boolean isEnableScopePersistence() {
return enableScopePersistence;
}

public void setEnableScopePersistence(boolean enableScopePersistence) {
this.enableScopePersistence = enableScopePersistence;
}

/** The BeforeSend callback */
public interface BeforeSendCallback {

Expand Down
5 changes: 5 additions & 0 deletions sentry/src/test/java/io/sentry/SentryOptionsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -603,4 +603,9 @@ class SentryOptionsTest {
assertTrue(options.isEnableSpotlight)
assertEquals("http://localhost:8080", options.spotlightConnectionUrl)
}

@Test
fun `when options are initialized, enableScopePersistence is set to true by default`() {
assertEquals(true, SentryOptions().isEnableScopePersistence)
}
}

0 comments on commit b0eb9b4

Please sign in to comment.