feat(android-sqlite): Add SentrySQLiteDriver (JAVA-275)#5466
Draft
0xadam-brown wants to merge 2 commits into
Draft
feat(android-sqlite): Add SentrySQLiteDriver (JAVA-275)#54660xadam-brown wants to merge 2 commits into
0xadam-brown wants to merge 2 commits into
Conversation
Introduces support for AndroidX's SQLiteDriver via a new SentrySQLiteDriver wrapper. SentrySQLiteDriver automatically creates Sentry spans for each SQL statement. It's the Driver API / KMP-compatible equivalent of SentrySupportSQLiteOpenHelper. --- Co-authored-by: Angus Holder <7407345+angusholder@users.noreply.github.com>
Contributor
|
📲 Install BuildsAndroid
|
Contributor
Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 91bb874 | 310.68 ms | 359.24 ms | 48.56 ms |
| ad8da22 | 314.38 ms | 352.29 ms | 37.91 ms |
| 27d7cf8 | 306.76 ms | 366.66 ms | 59.90 ms |
| 092f017 | 353.13 ms | 433.84 ms | 80.71 ms |
| b750b96 | 421.25 ms | 444.09 ms | 22.84 ms |
| a1eadfa | 345.67 ms | 411.26 ms | 65.59 ms |
| 5f14e5d | 325.76 ms | 368.32 ms | 42.56 ms |
| 22f4345 | 325.23 ms | 454.66 ms | 129.43 ms |
| 9054d65 | 330.94 ms | 403.24 ms | 72.30 ms |
| cf708bd | 408.35 ms | 458.98 ms | 50.63 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 91bb874 | 1.58 MiB | 2.13 MiB | 559.07 KiB |
| ad8da22 | 1.58 MiB | 2.29 MiB | 719.83 KiB |
| 27d7cf8 | 1.58 MiB | 2.12 MiB | 549.42 KiB |
| 092f017 | 0 B | 0 B | 0 B |
| b750b96 | 1.58 MiB | 2.10 MiB | 533.20 KiB |
| a1eadfa | 0 B | 0 B | 0 B |
| 5f14e5d | 1.58 MiB | 2.19 MiB | 620.00 KiB |
| 22f4345 | 1.58 MiB | 2.29 MiB | 719.83 KiB |
| 9054d65 | 1.58 MiB | 2.29 MiB | 723.38 KiB |
| cf708bd | 1.58 MiB | 2.11 MiB | 539.71 KiB |
8 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📜 Description
Adds
SentrySQLiteDriver, a new instrumentation path for Room 2.7+ apps that have migrated to theandroidx.sqlite.SQLiteDriverAPI.SQLiteDriver.open()to produce aSentrySQLiteConnectionSQLiteConnection.prepare()to produce aSentrySQLiteStatementSQLiteStatement.step()to create a Sentry span for each executed statementdb.nameto the basename of the path passed toSQLiteDriver.open()(e.g.,myapp.dbfrom/data/.../databases/myapp.db)LegacyInstrumentedSQLiteStatementto handle theSupportSQLiteDriveradapter path without duplicate wrappingNew classes live in
io.sentry.sqlite(notio.sentry.android.sqlite) so they depend only on the multiplatformandroidx.sqlite.*interfaces, keeping the door open for future KMP support.💡 Motivation and Context
Room 2.7 introduced the
SQLiteDriverAPI as a replacement forSupportSQLiteOpenHelper. Users upgrading to Room 2.7+ needed a way to instrument the new API surface without losing span coverage — and without producing duplicate spans if they're running both paths during a staged migration.Fixes JAVA-275.
💚 How did you test it?
Unit tests cover:
SentrySQLiteDriverdelegation and wrappingSentrySQLiteConnectiondelegation and wrappingSentrySQLiteStatementspan creation, cancellation, and success/error taggingSQLiteSpanRecorderspan lifecycle (start/finish/cancel)LegacyInstrumentedSQLiteStatementno-op passthrough📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps