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

Docs sentry android gradle plugin - tracing #4281

Merged
merged 8 commits into from
Oct 21, 2021
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,27 @@ The span finishes once the request has been executed. The span `status` depends
When the HTTP request throws an `IOException`, Sentry's SDK associates this exception to the running span. If you haven't set the SDK to swallow the exception and capture it, the span and SentryEvent will be linked when viewing it on the **Issue Details** page in sentry.io.

For more information see our [OkHttp integration](/platforms/android/configuration/integrations/okhttp/).

### SQLite and Room Instrumentation

<Note>

Supported in Sentry's Android SDK version `4.0.0` and above.

Supported in Sentry Android Gradle Plugin version `3.0.0` and above.

</Note>

The [Sentry Android Gradle Plugin](/platforms/android/proguard/#gradle-configuration) does the tracing auto instrumentation via bytecode manipulation for `SQLite` and `Room` libraries.

The Plugin injects a code snippet that starts a span out of the active span bound to the scope for each `CRUD` operation. The SDK sets the span `operation` to `db` and `description` to the SQL Query if available.

The span finishes once the operation has been executed. The span `status` is set to `SpanStatus.OK` if successful or `SpanStatus.INTERNAL_ERROR` if there was any error.

When the operation throws an `Exception`, Sentry's SDK associates this exception to the running span. If you haven't set the SDK to swallow the exception and capture it, the span and SentryEvent will be linked when viewing it on the **Issue Details** page in sentry.io.

<Note>

It's recommended to use `androidx.room` version `2.0.0` or above, since it supports incremental builds.

</Note>
26 changes: 24 additions & 2 deletions src/platforms/android/common/proguard.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ The Android SDK ships with ProGuard rules automatically defined; no further conf

</Note>

The `io.sentry.android.gradle` >= `3.0.0` requires [Android Gradle Plugin >= 7.0.0](https://developer.android.com/studio/releases/gradle-plugin#7-0-0).

## Gradle

Using Gradle (Android Studio) in your `app/build.gradle` add:
Expand Down Expand Up @@ -64,8 +66,9 @@ Additionally, we expose a few configuration values directly in your `app/build.g
```groovy
sentry {
// Enables or disables the automatic upload of mapping files
// during a build. If you disable this, you'll need to manually
// during a build. If you disable this, you'll need to manually
// upload the mapping files with sentry-cli when you do a release.
// Default is enabled.
autoUpload = true

// Disables or enables the automatic configuration of Native Symbols
Expand All @@ -79,14 +82,24 @@ sentry {
// you don't need to do it manually.
// Default is disabled.
includeNativeSources = false

// Enable or disable the tracing instrumentation.
// Does auto instrumentation for 'androidx.sqlite' and 'androidx.room' libraries.
// It starts and finishes a Span within any CRUD operation.
// Default is enabled.
// Only available v3.0.0 and above.
tracingInstrumentation {
enabled = true
}
}
```

```kotlin
sentry {
// Enables or disables the automatic upload of mapping files
// during a build. If you disable this, you'll need to manually
// during a build. If you disable this, you'll need to manually
// upload the mapping files with sentry-cli when you do a release.
// Default is enabled.
autoUpload.set(true)

// Disables or enables the automatic configuration of Native Symbols
Expand All @@ -100,6 +113,15 @@ sentry {
// you don't need to do it manually.
// Default is disabled.
includeNativeSources.set(false)

// Enable or disable the tracing instrumentation.
// Does auto instrumentation for 'androidx.sqlite' and 'androidx.room' libraries.
// It starts and finishes a Span within any CRUD operation.
// Default is enabled.
// Only available v3.0.0 and above.
tracingInstrumentation {
enabled.set(true)
}
}
```

Expand Down
34 changes: 34 additions & 0 deletions src/platforms/android/migration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,40 @@ redirect_from:
description: "Migrating between versions of Sentry's SDK for Android."
---

## Migrating from `io.sentry:sentry-android-gradle-plugin 2.x` to `io.sentry:sentry-android-gradle-plugin 3.0.0`

The `io.sentry.android.gradle` >= `3.0.0` requires [Android Gradle Plugin >= 7.0.0](https://developer.android.com/studio/releases/gradle-plugin#7-0-0).

The `tracingInstrumentation` feature requires the Sentry's Android SDK version `4.0.0` and above, otherwise it throws a `NoClassDefFoundError` exception.

The `io.sentry.android.gradle` enables the tracing instrumentation (via bytecode manipulation) for `androidx.sqlite` and `androidx.room` libraries by default, to disable it, see the code snippet bellow.

```groovy
sentry {
// Enable or disable the tracing instrumentation.
// Does auto instrumentation for 'androidx.sqlite' and 'androidx.room' libraries.
// It starts and finishes a Span within any CRUD operation.
// Default is enabled.
// Only available v3.0.0 and above.
tracingInstrumentation {
enabled = false
}
}
```

```kotlin
sentry {
// Enable or disable the tracing instrumentation.
// Does auto instrumentation for 'androidx.sqlite' and 'androidx.room' libraries.
// It starts and finishes a Span within any CRUD operation.
// Default is enabled.
// Only available v3.0.0 and above.
tracingInstrumentation {
enabled.set(false)
}
}
```

## Migrating from `io.sentry:sentry-android-gradle-plugin 1.x` to `io.sentry:sentry-android-gradle-plugin 2.0.0`

The `io.sentry.android.gradle` >= `2.0.0` requires [Android Gradle Plugin >= 4.0.0](https://developer.android.com/studio/releases/gradle-plugin#4-0-0).
Expand Down