Skip to content

chore(samples-android): Adapt SQLite demo screen to SAGP build mode#5568

Open
0xadam-brown wants to merge 1 commit into
mainfrom
chore/use-sagp-with-sample-sqlite-activity
Open

chore(samples-android): Adapt SQLite demo screen to SAGP build mode#5568
0xadam-brown wants to merge 1 commit into
mainfrom
chore/use-sagp-with-sample-sqlite-activity

Conversation

@0xadam-brown

Copy link
Copy Markdown
Member

📜 Description

Exposes a BuildConfig.USE_SAGP property from the recently introduced -PuseSagp flag (#5538).

Also updates the SQLite screen in the Android sample app so that it swizzles between auto-instrumenting vs manually wrapping SQLiteDriver, depending on the whether SAGP was applied to the build.

💡 Motivation and Context

Lets us test end-to-end our SentrySQLiteDriver and its auto-wiring via the SAGP.

JAVA-275, GRADLE-107

Screenshots

screenshot

Note the new pill that tells us whether or not the sample app was built via the SAGP. The SAGP auto-instruments SQLiteDriver when used with Room 2 and Room 3, but not when used directly – hence the buttons' enabled vs disabled states. (SQLDelight doesn't support SQLiteDriver whatsoever.)

💚 How did you test it?

Manually via the samples app:

./gradlew :sentry-samples:sentry-samples-android:installDebug -PuseSagp

📝 Checklist

  • I added GH Issue ID & Linear ID
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

🔮 Next steps

Exposes a `BuildConfig.USE_SAGP` property from the recently introduced -PuseSagp flag ([#5538](#5538)).

Lets us update the SQLite screen in the Android sample app so that it swizzles between auto-instrumenting vs manually wrapping `SQLiteDriver`, depending on the whether SAGP was applied to the build.
@sentry

sentry Bot commented Jun 18, 2026

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
SDK Size io.sentry.tests.size 8.44.0 (1) release

⚙️ sentry-android Build Distribution Settings

Comment on lines +744 to +746
SqlDemo.DRIVER_DIRECT -> SAGP_DIRECT_DRIVER_MESSAGE
else -> null
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The sagpDisabledReason function incorrectly leaves the BRIDGE_DIRECT button enabled in SAGP mode, even though its underlying direct SQLiteDriver usage is not instrumented, misleading testers.
Severity: LOW

Suggested Fix

Update the when expression within the sagpDisabledReason function to also handle the SqlDemo.BRIDGE_DIRECT case when BuildConfig.USE_SAGP is true. This will ensure the button for this demo is disabled, correctly reflecting that direct SQLiteDriver usage is not auto-instrumented by SAGP.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location:
sentry-samples/sentry-samples-android/src/main/java/io/sentry/samples/android/sqlite/SQLiteActivity.kt#L744-L746

Potential issue: When the sample app is built with `USE_SAGP = true`, the
`sagpDisabledReason` function only disables the button for `DRIVER_DIRECT` usage. It
fails to also disable the `BRIDGE_DIRECT` button. The `BRIDGE_DIRECT` case also uses
`SQLiteDriver` directly without Room, a scenario which the Sentry Android Gradle Plugin
(SAGP) does not instrument. This results in a misleading UI where the `BRIDGE_DIRECT`
button is enabled and its subtitle suggests 'SAGP auto-wrap', but clicking it produces
no Sentry spans, creating a false negative for testers.

Did we get this right? 👍 / 👎 to inform future reviews.

@github-actions

Copy link
Copy Markdown
Contributor

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 312.37 ms 359.30 ms 46.93 ms
Size 0 B 0 B 0 B

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
a416a65 333.78 ms 410.37 ms 76.59 ms
d15471f 304.55 ms 408.43 ms 103.87 ms
ca6b6d8 380.45 ms 460.38 ms 79.93 ms
c8125f3 397.65 ms 485.14 ms 87.49 ms
b936425 302.69 ms 372.86 ms 70.17 ms
ed33deb 334.19 ms 362.30 ms 28.11 ms
cf708bd 408.35 ms 458.98 ms 50.63 ms
eb95ded 317.51 ms 369.08 ms 51.57 ms
a5ab36f 320.47 ms 389.77 ms 69.30 ms
80fd6ad 321.06 ms 375.79 ms 54.73 ms

App size

Revision Plain With Sentry Diff
a416a65 1.58 MiB 2.12 MiB 555.26 KiB
d15471f 1.58 MiB 2.13 MiB 559.54 KiB
ca6b6d8 0 B 0 B 0 B
c8125f3 1.58 MiB 2.10 MiB 532.32 KiB
b936425 0 B 0 B 0 B
ed33deb 1.58 MiB 2.13 MiB 559.52 KiB
cf708bd 1.58 MiB 2.11 MiB 539.71 KiB
eb95ded 0 B 0 B 0 B
a5ab36f 1.58 MiB 2.12 MiB 555.26 KiB
80fd6ad 0 B 0 B 0 B

@runningcode runningcode left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks great! love the debugging UI with the indication of how the app was built!

versionCode = 2
versionName = project.version.toString()

buildConfigField(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: i thought they created a new API that takes a provider here instead of eagerly resolving. not a big deal here since it doesn't matter either way for performance.

}

@androidx.compose.runtime.Composable
@Composable

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for fixing! im surprised spotless doesn't have a check for this.

private val SECTION_HEADER_HEIGHT = 28.dp

private const val SAGP_DIRECT_DRIVER_MESSAGE =
"SAGP doesn't auto-instrument SQLiteDriver for direct use"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is because it isn't supported right? If so I suggest this to differentiate from it being disabled.

Suggested change
"SAGP doesn't auto-instrument SQLiteDriver for direct use"
"SAGP doesn't support auto-instrument SQLiteDriver for direct use"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants