Skip to content
Merged
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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## Unreleased

### Features

- Add experimental `SentrySQLiteDriver` to `sentry-android-sqlite` for instrumenting `androidx.sqlite.SQLiteDriver` ([#5563](https://github.com/getsentry/sentry-java/pull/5563))
- To use it, pass `SQLiteDriver` to `SentrySQLiteDriver.create(...)`
- Requires `androidx.sqlite:sqlite` (2.5.0+) on runtime classpath (typically provided by Room or SQLDelight)

## 8.44.0

### Features
Expand Down
12 changes: 12 additions & 0 deletions sentry-android-sqlite/api/sentry-android-sqlite.api
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,15 @@ public final class io/sentry/android/sqlite/SentrySupportSQLiteOpenHelper$Compan
public final fun create (Landroidx/sqlite/db/SupportSQLiteOpenHelper;)Landroidx/sqlite/db/SupportSQLiteOpenHelper;
}

public final class io/sentry/sqlite/SentrySQLiteDriver : androidx/sqlite/SQLiteDriver {
public static final field Companion Lio/sentry/sqlite/SentrySQLiteDriver$Companion;
public synthetic fun <init> (Landroidx/sqlite/SQLiteDriver;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
public static final fun create (Landroidx/sqlite/SQLiteDriver;)Landroidx/sqlite/SQLiteDriver;
public fun hasConnectionPool ()Z
public fun open (Ljava/lang/String;)Landroidx/sqlite/SQLiteConnection;
}

public final class io/sentry/sqlite/SentrySQLiteDriver$Companion {
public final fun create (Landroidx/sqlite/SQLiteDriver;)Landroidx/sqlite/SQLiteDriver;
}

5 changes: 5 additions & 0 deletions sentry-android-sqlite/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ android {

buildFeatures { buildConfig = true }

// Needed b/c Kotlin 1.4.x would otherwise pull in an older version without the annotations we
// want.
configurations.all { resolutionStrategy.force(libs.jetbrains.annotations.get()) }

androidComponents.beforeVariants {
it.enable = !Config.Android.shouldSkipDebugVariant(it.buildType)
}
Expand All @@ -65,6 +69,7 @@ dependencies {
api(projects.sentry)

compileOnly(libs.androidx.sqlite)
compileOnly(libs.jetbrains.annotations)

implementation(kotlin(Config.kotlinStdLib, Config.kotlinStdLibVersionAndroid))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import androidx.sqlite.SQLiteDriver
import io.sentry.ScopesAdapter
import io.sentry.SentryIntegrationPackageStorage
import io.sentry.SentryLevel
import org.jetbrains.annotations.ApiStatus

/**
* Wraps a [SQLiteDriver] and automatically adds spans for each SQL statement it executes.
Expand All @@ -28,13 +29,16 @@ import io.sentry.SentryLevel
*
* @param delegate The [SQLiteDriver] instance to delegate calls to.
*/
internal class SentrySQLiteDriver private constructor(private val delegate: SQLiteDriver) :
@ApiStatus.Experimental
public class SentrySQLiteDriver private constructor(private val delegate: SQLiteDriver) :
SQLiteDriver {

init {
SentryIntegrationPackageStorage.getInstance().addIntegration("SQLiteDriver")
}

@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("hasConnectionPool")
Comment thread
0xadam-brown marked this conversation as resolved.
override val hasConnectionPool: Boolean
get() =
try {
Expand Down Expand Up @@ -66,14 +70,14 @@ internal class SentrySQLiteDriver private constructor(private val delegate: SQLi
}
}

companion object {
public companion object {

/**
* Wraps the provided delegate in a [SentrySQLiteDriver]. Returns the delegate as-is if already
* wrapped.
*/
@JvmStatic
fun create(delegate: SQLiteDriver): SQLiteDriver =
public fun create(delegate: SQLiteDriver): SQLiteDriver =
delegate as? SentrySQLiteDriver ?: SentrySQLiteDriver(delegate)
}
}
Loading