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
18 changes: 9 additions & 9 deletions .cursor/rules/options.mdc
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ Allows setting options via `AndroidManifest.xml` `<meta-data>` tags.
- Add a `static final String` constant for the key
- Read it in `applyMetadata()` using `readBool(metadata, logger, CONSTANT, defaultValue)`
- Apply automatic-source options directly, for example
`options.setEnableLogcatLogs(...)` for `io.sentry.logcat.logs.enabled`
`options.setLogcatLogsEnabled(...)` for `io.sentry.logcat.logs.enabled`
- Do not add or restore `io.sentry.logs.enabled` or `io.sentry.metrics.enabled`; those aggregate
keys are obsolete and are read only to emit migration warnings.

Expand All @@ -89,8 +89,8 @@ Allows setting options via `AndroidManifest.xml` `<meta-data>` tags.

`SentryProperties` extends `SentryOptions`, so bindable namespaced behavior options are available
through the `SentryOptions` class hierarchy. Spring-owned integration controls belong to a Spring
namespace instead. For example, `SentryProperties.Logging.enableLogs` binds to
`sentry.logging.enable-logs` and controls Logs forwarding from the auto-configured Logback
namespace instead. For example, `SentryProperties.Logging.logsEnabled` binds to
`sentry.logging.logs-enabled` and controls Logs forwarding from the auto-configured Logback
appender. `sentry.logging.enabled` separately controls whether that appender is installed.

Do not add or restore `sentry.logs.enabled` or `sentry.metrics.enabled`. Spring detects those legacy
Expand All @@ -110,12 +110,12 @@ They capture whenever their scopes are enabled, then apply signal behavior such

Automatic integrations must check their source-local opt-in without affecting their existing event
or breadcrumb paths. Current Logs controls are:
- Logback: appender `enableLogs`
- Log4j2: appender `enableLogs`
- JUL: handler `enableLogs`
- Spring Boot Logback: `sentry.logging.enable-logs`
- Timber: `enableTimberLogs` / `io.sentry.timber.logs.enabled`
- Logcat: `enableLogcatLogs` / `io.sentry.logcat.logs.enabled`
- Logback: appender `logsEnabled`
- Log4j2: appender `logsEnabled`
- JUL: handler `logsEnabled`
- Spring Boot Logback: `sentry.logging.logs-enabled`
- Timber: `timberLogsEnabled` / `io.sentry.timber.logs.enabled`
- Logcat: `logcatLogsEnabled` / `io.sentry.logcat.logs.enabled`

All source-local options default to `false` and gate only Sentry Logs forwarding.

Expand Down
8 changes: 4 additions & 4 deletions sentry-android-core/api/sentry-android-core.api
Original file line number Diff line number Diff line change
Expand Up @@ -408,11 +408,13 @@ public final class io/sentry/android/core/SentryAndroidOptions : io/sentry/Sentr
public fun getBeforeViewHierarchyCaptureCallback ()Lio/sentry/android/core/SentryAndroidOptions$BeforeCaptureCallback;
public fun getDebugImagesLoader ()Lio/sentry/android/core/IDebugImagesLoader;
public fun getFrameMetricsCollector ()Lio/sentry/android/core/internal/util/SentryFrameMetricsCollector;
public fun getLogcatLogsEnabled ()Z
public fun getNativeSdkName ()Ljava/lang/String;
public fun getNdkAppHangTimeoutIntervalMillis ()J
public fun getNdkHandlerStrategy ()I
public fun getScreenshot ()Lio/sentry/android/core/SentryScreenshotOptions;
public fun getStartupCrashDurationThresholdMillis ()J
public fun getTimberLogsEnabled ()Z
public fun isAnrEnabled ()Z
public fun isAnrProfilingEnabled ()Z
public fun isAnrReportInDebug ()Z
Expand All @@ -430,7 +432,6 @@ public final class io/sentry/android/core/SentryAndroidOptions : io/sentry/Sentr
public fun isEnableAutoActivityLifecycleTracing ()Z
public fun isEnableAutoTraceIdGeneration ()Z
public fun isEnableFramesTracking ()Z
public fun isEnableLogcatLogs ()Z
public fun isEnableNdk ()Z
public fun isEnableNdkAppHangTracking ()Z
public fun isEnableNetworkEventBreadcrumbs ()Z
Expand All @@ -440,7 +441,6 @@ public final class io/sentry/android/core/SentryAndroidOptions : io/sentry/Sentr
public fun isEnableStandaloneAppStartTracing ()Z
public fun isEnableSystemEventBreadcrumbs ()Z
public fun isEnableSystemEventBreadcrumbsExtras ()Z
public fun isEnableTimberLogs ()Z
public fun isReportHistoricalAnrs ()Z
public fun isReportHistoricalTombstones ()Z
public fun isTombstoneEnabled ()Z
Expand All @@ -465,7 +465,6 @@ public final class io/sentry/android/core/SentryAndroidOptions : io/sentry/Sentr
public fun setEnableAutoActivityLifecycleTracing (Z)V
public fun setEnableAutoTraceIdGeneration (Z)V
public fun setEnableFramesTracking (Z)V
public fun setEnableLogcatLogs (Z)V
public fun setEnableNdk (Z)V
public fun setEnableNdkAppHangTracking (Z)V
public fun setEnableNetworkEventBreadcrumbs (Z)V
Expand All @@ -475,13 +474,14 @@ public final class io/sentry/android/core/SentryAndroidOptions : io/sentry/Sentr
public fun setEnableStandaloneAppStartTracing (Z)V
public fun setEnableSystemEventBreadcrumbs (Z)V
public fun setEnableSystemEventBreadcrumbsExtras (Z)V
public fun setEnableTimberLogs (Z)V
public fun setFrameMetricsCollector (Lio/sentry/android/core/internal/util/SentryFrameMetricsCollector;)V
public fun setLogcatLogsEnabled (Z)V
public fun setNativeHandlerStrategy (Lio/sentry/android/core/NdkHandlerStrategy;)V
public fun setNativeSdkName (Ljava/lang/String;)V
public fun setNdkAppHangTimeoutIntervalMillis (J)V
public fun setReportHistoricalAnrs (Z)V
public fun setReportHistoricalTombstones (Z)V
public fun setTimberLogsEnabled (Z)V
public fun setTombstoneEnabled (Z)V
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ static void installDefaultIntegrations(
}

if (isTimberAvailable) {
options.addIntegration(new SentryTimberIntegration(options::isEnableTimberLogs));
options.addIntegration(new SentryTimberIntegration(options::getTimberLogsEnabled));
}
options.addIntegration(new AppComponentsBreadcrumbsIntegration(context));
options.addIntegration(new SystemEventsBreadcrumbsIntegration(context));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -746,11 +746,11 @@ static void applyMetadata(
}
}

options.setEnableTimberLogs(
readBool(metadata, logger, ENABLE_TIMBER_LOGS, options.isEnableTimberLogs()));
options.setTimberLogsEnabled(
readBool(metadata, logger, ENABLE_TIMBER_LOGS, options.getTimberLogsEnabled()));

options.setEnableLogcatLogs(
readBool(metadata, logger, ENABLE_LOGCAT_LOGS, options.isEnableLogcatLogs()));
options.setLogcatLogsEnabled(
readBool(metadata, logger, ENABLE_LOGCAT_LOGS, options.getLogcatLogsEnabled()));

final @NotNull SentryFeedbackOptions feedbackOptions = options.getFeedbackOptions();
feedbackOptions.setNameRequired(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ public final class SentryAndroidOptions extends SentryOptions {
private boolean enableNetworkEventBreadcrumbs = true;

/** Enable or disable automatic Sentry Logs capture from Timber. Default is disabled. */
private boolean enableTimberLogs = false;
private boolean timberLogsEnabled = false;

/** Enable or disable automatic Sentry Logs capture from Logcat. Default is disabled. */
private boolean enableLogcatLogs = false;
private boolean logcatLogsEnabled = false;

/**
* Enables the Auto instrumentation for Activity lifecycle tracing.
Expand Down Expand Up @@ -463,20 +463,20 @@ public void setEnableNetworkEventBreadcrumbs(boolean enableNetworkEventBreadcrum
this.enableNetworkEventBreadcrumbs = enableNetworkEventBreadcrumbs;
}

public boolean isEnableTimberLogs() {
return enableTimberLogs;
public boolean getTimberLogsEnabled() {
return timberLogsEnabled;
}

public void setEnableTimberLogs(boolean enableTimberLogs) {
this.enableTimberLogs = enableTimberLogs;
public void setTimberLogsEnabled(boolean timberLogsEnabled) {
this.timberLogsEnabled = timberLogsEnabled;
}

public boolean isEnableLogcatLogs() {
return enableLogcatLogs;
public boolean getLogcatLogsEnabled() {
return logcatLogsEnabled;
}

public void setEnableLogcatLogs(boolean enableLogcatLogs) {
this.enableLogcatLogs = enableLogcatLogs;
public void setLogcatLogsEnabled(boolean logcatLogsEnabled) {
this.logcatLogsEnabled = logcatLogsEnabled;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ private static void addAsLog(
final @NotNull ScopesAdapter scopes = ScopesAdapter.getInstance();
final @NotNull SentryOptions options = scopes.getOptions();
if (!(options instanceof SentryAndroidOptions)
|| !((SentryAndroidOptions) options).isEnableLogcatLogs()) {
|| !((SentryAndroidOptions) options).getLogcatLogsEnabled()) {
return;
}
final @Nullable String trMessage = tr != null ? tr.getMessage() : null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -704,18 +704,18 @@ class AndroidOptionsInitializerTest {
val actual =
fixture.sentryOptions.integrations.firstOrNull { it is SentryTimberIntegration }
as SentryTimberIntegration
assertFalse(actual.enableLogs)
assertFalse(actual.logsEnabled)
}

@Test
fun `SentryTimberIntegration receives Timber logs option`() {
fixture.sentryOptions.isEnableTimberLogs = true
fixture.sentryOptions.timberLogsEnabled = true
fixture.initSutWithClassLoader(isTimberAvailable = true)

val actual =
fixture.sentryOptions.integrations.firstOrNull { it is SentryTimberIntegration }
as SentryTimberIntegration
assertTrue(actual.enableLogs)
assertTrue(actual.logsEnabled)
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1975,14 +1975,14 @@ class ManifestMetadataReaderTest {
"integrations now require their own opt-ins.",
*emptyArray(),
)
assertThat(fixture.options.isEnableTimberLogs).isFalse()
assertThat(fixture.options.isEnableLogcatLogs).isFalse()
assertThat(fixture.options.timberLogsEnabled).isFalse()
assertThat(fixture.options.logcatLogsEnabled).isFalse()
}

@Test
fun `applyMetadata warns when legacy logs enabled metadata is false`() {
fixture.options.isEnableTimberLogs = true
fixture.options.isEnableLogcatLogs = true
fixture.options.timberLogsEnabled = true
fixture.options.logcatLogsEnabled = true
val bundle = bundleOf(ManifestMetadataReader.ENABLE_LOGS to false)
val context = fixture.getContext(metaData = bundle)

Expand All @@ -1996,8 +1996,8 @@ class ManifestMetadataReaderTest {
"enabled through their own opt-ins.",
*emptyArray(),
)
assertThat(fixture.options.isEnableTimberLogs).isTrue()
assertThat(fixture.options.isEnableLogcatLogs).isTrue()
assertThat(fixture.options.timberLogsEnabled).isTrue()
assertThat(fixture.options.logcatLogsEnabled).isTrue()
}

@Test
Expand All @@ -2006,7 +2006,7 @@ class ManifestMetadataReaderTest {

ManifestMetadataReader.applyMetadata(context, fixture.options, fixture.buildInfoProvider)

assertFalse(fixture.options.isEnableTimberLogs)
assertFalse(fixture.options.timberLogsEnabled)
}

@Test
Expand All @@ -2016,7 +2016,7 @@ class ManifestMetadataReaderTest {

ManifestMetadataReader.applyMetadata(context, fixture.options, fixture.buildInfoProvider)

assertTrue(fixture.options.isEnableTimberLogs)
assertTrue(fixture.options.timberLogsEnabled)
}

@Test
Expand All @@ -2025,7 +2025,7 @@ class ManifestMetadataReaderTest {

ManifestMetadataReader.applyMetadata(context, fixture.options, fixture.buildInfoProvider)

assertThat(fixture.options.isEnableLogcatLogs).isFalse()
assertThat(fixture.options.logcatLogsEnabled).isFalse()
}

@Test
Expand All @@ -2035,18 +2035,18 @@ class ManifestMetadataReaderTest {

ManifestMetadataReader.applyMetadata(context, fixture.options, fixture.buildInfoProvider)

assertThat(fixture.options.isEnableLogcatLogs).isTrue()
assertThat(fixture.options.logcatLogsEnabled).isTrue()
}

@Test
fun `applyMetadata reads Logcat logs disabled to options`() {
fixture.options.isEnableLogcatLogs = true
fixture.options.logcatLogsEnabled = true
val bundle = bundleOf(ManifestMetadataReader.ENABLE_LOGCAT_LOGS to false)
val context = fixture.getContext(metaData = bundle)

ManifestMetadataReader.applyMetadata(context, fixture.options, fixture.buildInfoProvider)

assertThat(fixture.options.isEnableLogcatLogs).isFalse()
assertThat(fixture.options.logcatLogsEnabled).isFalse()
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,28 +98,28 @@ class SentryAndroidOptionsTest {
fun `Timber logs are disabled by default`() {
val sentryOptions = SentryAndroidOptions()

assertFalse(sentryOptions.isEnableTimberLogs)
assertFalse(sentryOptions.timberLogsEnabled)
}

@Test
fun `Timber logs can be enabled`() {
val sentryOptions = SentryAndroidOptions()
sentryOptions.isEnableTimberLogs = true
sentryOptions.timberLogsEnabled = true

assertTrue(sentryOptions.isEnableTimberLogs)
assertTrue(sentryOptions.timberLogsEnabled)
}

@Test
fun `Logcat logs are disabled by default`() {
assertThat(SentryAndroidOptions().isEnableLogcatLogs).isFalse()
assertThat(SentryAndroidOptions().logcatLogsEnabled).isFalse()
}

@Test
fun `Logcat logs can be enabled`() {
val sentryOptions = SentryAndroidOptions()
sentryOptions.isEnableLogcatLogs = true
sentryOptions.logcatLogsEnabled = true

assertThat(sentryOptions.isEnableLogcatLogs).isTrue()
assertThat(sentryOptions.logcatLogsEnabled).isTrue()
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ class SentryAndroidTest {
fun `auto-installed Timber integration uses Logs option set in configuration callback`() {
val logs = mutableListOf<SentryLogEvent>()
fixture.initSut { options ->
options.isEnableTimberLogs = true
options.timberLogsEnabled = true
options.logs.beforeSend =
SentryOptions.Logs.BeforeSendLogCallback { log ->
logs.add(log)
Expand All @@ -268,7 +268,7 @@ class SentryAndroidTest {
val logs = mutableListOf<SentryLogEvent>()

initForTest(mockContext) { options ->
options.isEnableTimberLogs = false
options.timberLogsEnabled = false
options.logs.beforeSend =
SentryOptions.Logs.BeforeSendLogCallback { log ->
logs.add(log)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class SentryLogcatAdapterTest {
val logs = mutableListOf<SentryLogEvent>()

fun initSut(
enableLogcatLogs: Boolean? = true,
logcatLogsEnabled: Boolean? = true,
metadata: Bundle = Bundle(),
options: Sentry.OptionsConfiguration<SentryAndroidOptions>? = null,
) {
Expand All @@ -39,8 +39,8 @@ class SentryLogcatAdapterTest {
breadcrumbs.add(breadcrumb)
breadcrumb
}
if (enableLogcatLogs != null) {
it.isEnableLogcatLogs = enableLogcatLogs
if (logcatLogsEnabled != null) {
it.logcatLogsEnabled = logcatLogsEnabled
}
it.logs.beforeSend =
SentryOptions.Logs.BeforeSendLogCallback { logEvent ->
Expand All @@ -66,7 +66,7 @@ class SentryLogcatAdapterTest {

@Test
fun `Logcat logs are disabled by default while breadcrumbs and Android Log remain enabled`() {
fixture.initSut(enableLogcatLogs = null)
fixture.initSut(logcatLogsEnabled = null)

SentryLogcatAdapter.d(tag, commonMsg)

Expand All @@ -77,7 +77,7 @@ class SentryLogcatAdapterTest {

@Test
fun `Logcat logs can be enabled through Android options`() {
fixture.initSut(enableLogcatLogs = true)
fixture.initSut(logcatLogsEnabled = true)

SentryLogcatAdapter.d(tag, commonMsg)

Expand All @@ -87,7 +87,7 @@ class SentryLogcatAdapterTest {
@Test
fun `Logcat logs can be enabled through manifest metadata`() {
val metadata = Bundle().apply { putBoolean(ManifestMetadataReader.ENABLE_LOGCAT_LOGS, true) }
fixture.initSut(enableLogcatLogs = null, metadata = metadata)
fixture.initSut(logcatLogsEnabled = null, metadata = metadata)

SentryLogcatAdapter.d(tag, commonMsg)

Expand Down
2 changes: 1 addition & 1 deletion sentry-android-timber/api/sentry-android-timber.api
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public final class io/sentry/android/timber/SentryTimberIntegration : io/sentry/
public fun <init> (Lio/sentry/util/LazyEvaluator$Evaluator;)V
public fun <init> (Z)V
public fun close ()V
public final fun getEnableLogs ()Z
public final fun getLogsEnabled ()Z
public final fun getMinBreadcrumbLevel ()Lio/sentry/SentryLevel;
public final fun getMinEventLevel ()Lio/sentry/SentryLevel;
public final fun getMinLogsLevel ()Lio/sentry/SentryLogLevel;
Expand Down
Loading
Loading