Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Room DB instrumentation does not work with custom SQLite open helper #234

Closed
3 of 6 tasks
vinaysshenoy opened this issue Nov 16, 2021 · 6 comments
Closed
3 of 6 tasks

Comments

@vinaysshenoy
Copy link

Android Gradle Plugin:
7.0.3

Gradle:
7.3

Optimizer:

  • ProGuard
  • R8

Have you created the sentry.properties file?

  • Yes -> app/src/release/resources
  • No

SDKs:

  • sentry-android -> 5.3.0
  • sentry-react-native -> which version?

I have the following issue:
Room database instrumentation does not instrument database queries for custom SQLite open helper.

In our project, we package our version of SQLite using https://github.com/requery/sqlite-android and use their open helper factory when setting up Room.

Steps to reproduce:

return Room.databaseBuilder(appContext, AppDatabase::class.java, "red-db")
        .openHelperFactory(RequerySQLiteOpenHelperFactory())
        .build()
  • Run the project with Sentry DB instrumentation enabled.

Actual result:

  • DB instrumentation does not get reported to Sentry.

Expected result:

  • DB instrumentation should get reported to Sentry. This can be confirmed by commenting out the line that provides a custom factory and building the project and running again.
@romtsn
Copy link
Member

romtsn commented Nov 16, 2021

Thanks a lot for trying the new functionality out, really appreciate that.

Unfortunately, at the moment we only support the standard Room setup (i.e. when it's backed by androidx.sqlite lib). This is a good enhancement though, we may consider adding a support in the future.

I've updated docs mentioning your case.

@vinaysshenoy
Copy link
Author

Thanks a lot for trying the new functionality out, really appreciate that.

Unfortunately, at the moment we only support the standard Room setup (i.e. when it's backed by androidx.sqlite lib. This is a good enhancement though, we may consider adding a support in the future.

I've updated docs mentioning your case.

Interesting, I thought the bytecode instrumentation was being done at the open helper level, not at the sqlite level itself. Will keep an eye out if this enhancement ever makes it into the library.

In the meantime, would you be able to suggest workarounds we can do to instrument our current setup on Sentry?

@marandaneto
Copy link
Contributor

@vinaysshenoy you can still https://docs.sentry.io/platforms/android/performance/instrumentation/custom-instrumentation/

@romtsn
Copy link
Member

romtsn commented Nov 16, 2021

Interesting, I thought the bytecode instrumentation was being done at the open helper level, not at the sqlite level itself. Will keep an eye out if this enhancement ever makes it into the library.

Yeah this is a good point, perhaps, we should switch over to that approach, as we can cover all integrations with that. Still would need to do a feasibility check first.

You should still see the room spans in the Sentry Dashboard at the moment (room query with mapping) but no actual SQL queries, right? If you want our instrumentation to kick in you'd need to somehow wire it up with FrameworkSQLiteDatabase. To me, this would mean having your own implementations of SQLiteOpenHelper and RequerySQLiteOpenHelperFactory (can be just copied over as is), and then here you'd

return FrameworkSQLiteDatabase(db)

since it accepts a delegate. Not sure if it'd break any requery logic though

@philipphofmann philipphofmann moved this from Needs Discussion to Backlog in Mobile & Cross Platform SDK Nov 17, 2021
@vinaysshenoy
Copy link
Author

@romtsn Nope, the spans don't show up. The only spans which show are the ones for the Android workmanager database, which are managed on a platform SQLite version.

Screenshot 2021-11-22 at 11 11 18 AM

@romtsn romtsn moved this from Backlog to Needs Discussion in Mobile & Cross Platform SDK Apr 27, 2022
@romtsn romtsn moved this from Needs Discussion to Needs Investigation in Mobile & Cross Platform SDK Apr 27, 2022
@romtsn romtsn moved this from Needs Investigation to Needs Discussion in Mobile & Cross Platform SDK Apr 27, 2022
@romtsn romtsn moved this from Needs Discussion to Backlog in Mobile & Cross Platform SDK Apr 27, 2022
@romtsn
Copy link
Member

romtsn commented Jun 13, 2023

@vinaysshenoy with the next version of the gradle plugin (3.11.0) we'll be automatically instrumenting any class that implements androidx.sqlite.db.SupportSQLiteOpenHelper.Factory, including requery.

We'll ship the new version tomorrow, please let us know if the new instrumentation is gonna work for you.

Closed by #502.

@romtsn romtsn closed this as completed Jun 13, 2023
@github-project-automation github-project-automation bot moved this from Backlog to Done in Mobile & Cross Platform SDK Jun 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

No branches or pull requests

4 participants