The sentry-android-okhttp library provides OkHttp support for Sentry via the OkHttp Interceptor. The source can be found on GitHub.

On this page, we get you up and running with Sentry's OkHttp Integration, so that it will automatically add a breadcrumb and start a span out of the active span bound to the scope for each HTTP Request.


Sentry captures data by adding an OkHttp Interceptor. To add the OkHttp integration, initialize the Android SDK, then add the sentry-android-okhttp dependency. Using Gradle:

implementation 'io.sentry:sentry-android:4.4.0-alpha.1'
implementation 'io.sentry:sentry-android-okhttp:4.4.0-alpha.1'


Configuration should happen once you create your OkHttpClient instance.

import okhttp3.OkHttpClient
import io.sentry.android.okhttp.SentryOkHttpInterceptor

private val client = OkHttpClient.Builder()


This snippet includes a HTTP Request and captures an intentional message, so you can test that everything is working as soon as you set it up:

import io.sentry.android.okhttp.SentryOkHttpInterceptor
import io.sentry.Sentry
import java.io.IOException
import okhttp3.OkHttpClient
import okhttp3.Request

fun run(url: String): String? {
  val request = Request.Builder()

  val bodyStr = client

  Sentry.captureMessage("The Message $bodyStr")

  return bodyStr

To view and resolve the recorded message, log into sentry.io and open your project. Clicking on the error's title will open a page where you can see detailed information and mark it as resolved.

You can edit this page on GitHub.