Skip to content
Closed
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

- Add release information args to proguard mapping upload task ([#476](https://github.com/getsentry/sentry-android-gradle-plugin/pull/476))
- Auto install Sentry integrations for Java Backend, Desktop, etc. ([#521](https://github.com/getsentry/sentry-android-gradle-plugin/pull/521))
- (Internal change) Use Hub.getSpan instead of Sentry.getSpan for database instrumentation ([#535](https://github.com/getsentry/sentry-android-gradle-plugin/pull/535))

### Dependencies

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ abstract class AbstractSpanAddingMethodVisitor(
}

/*
ISpan span = Sentry.getSpan()
IHub hub = HubAdapter.getInstance();
ISpan span = hub.getSpan();
ISpan child = null;
if (span != null) {
child = span.startChild("db", <description>);
Expand All @@ -53,11 +54,23 @@ abstract class AbstractSpanAddingMethodVisitor(
) {
visitMethodInsn(
Opcodes.INVOKESTATIC,
"io/sentry/Sentry",
"io/sentry/HubAdapter",
"getInstance",
"()Lio/sentry/HubAdapter;",
/* isInterface = */ false
)
val hubIdx = newLocal(Types.HUB)
visitVarInsn(Opcodes.ASTORE, hubIdx) // hub
visitVarInsn(Opcodes.ALOAD, hubIdx) // hub

visitMethodInsn(
Opcodes.INVOKEVIRTUAL,
"io/sentry/IHub",
"getSpan",
"()Lio/sentry/ISpan;",
/* isInterface = */ false
)

val spanIndex = newLocal(Types.SPAN)
childIndex = newLocal(Types.SPAN)
visitVarInsn(Opcodes.ASTORE, spanIndex) // span
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ object Types {
val ITERATOR = Type.getType("Ljava/util/Iterator;")
val COLLECTION = Type.getType("Ljava/util/Collection;")

val HUB = Type.getType("Lio/sentry/IHub;")

// DB
val SQL_EXCEPTION = Type.getType("Landroid/database/SQLException;")
val CURSOR = Type.getType("Landroid/database/Cursor;")
Expand Down