sentry-android-gradle-plugin
sentry-android-gradle-plugin copied to clipboard
Option to ignore spans coming from 3rd party dependencies
At the moment we are instrumenting all Room classes as well as anything that uses androidx.sqlite internally. This might be unwanted behavior for some users, because it brings a lot of noise, and it becomes hard to find actual db operations done by the target app.
Example - here all spans are reported from the 3rd party lib, except the last one

The potential solution is to filter 3rd parties out on the Gradle Plugin site, providing some option in the plugin configuration, like a list of ignored package names, with some reasonable defaults (e.g. ignore androidx.work by default). Note: we'd need some smart logic to ignore calls happening in the androidx.sqlite, because there we have no way of knowing the caller, since we are instrumenting the internals of it.
The ultimate goal would be to send this info as part of a span, and then have a toggle on Sentry dashboard to filter out 3rd-party spans.
What we came up with in the SDK evolution meeting is actually setting a source for a span. So we need to investigate whether it's possible to get the database name or at least the module/package/jar where the query is coming from and then send this information along the span.
The source tag/field will help in grouping the spans, so the users can collapse those that are not relevant to their app.
This requires a bigger project (we need to have access to all .class files of the APK, this is not possible with the new AGP API) - potentially we need our custom Gradle task doing what AGP does, but it would be nice if we don't and we still can supply the classpath using new AGP API.
After this ^ is implemented, we can traverse the classes and search for callers of the db queries to set them as source afterwards