From a33abc984c10fd40fe30f5f39ac7d40eff2dad77 Mon Sep 17 00:00:00 2001 From: Lukas Bloder Date: Mon, 21 Sep 2026 15:15:04 +0200 Subject: [PATCH 1/2] add okhttp spring autoconfig documentation --- .../common/tracing/instrumentation/okhttp.mdx | 40 ++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/docs/platforms/java/common/tracing/instrumentation/okhttp.mdx b/docs/platforms/java/common/tracing/instrumentation/okhttp.mdx index a0b582b457a091..58646db2a644e1 100644 --- a/docs/platforms/java/common/tracing/instrumentation/okhttp.mdx +++ b/docs/platforms/java/common/tracing/instrumentation/okhttp.mdx @@ -41,7 +41,45 @@ For other dependency managers, see the [central Maven repository](https://search ## Configure -Configuration should happen once you create your `OkHttpClient` instance. + + +### Configure Spring Boot Automatically + +Sentry's Spring Boot 2, 3, and 4 integrations automatically instrument every `OkHttpClient` bean managed by Spring when you enable this option. Install `sentry-okhttp`, configure `sentry.dsn`, and enable the integration in your application configuration: + +```properties {tabTitle:application.properties} {filename:src/main/resources/application.properties} +sentry.clients.ok-http-enabled=true +``` + +```yaml {tabTitle:application.yml} {filename:src/main/resources/application.yml} +sentry: + clients: + ok-http-enabled: true +``` + +The auto-configuration preserves each client's existing configuration, interceptors, and event listeners. It adds the Sentry interceptor only once and doesn't create an `OkHttpClient` bean if your application hasn't defined one. + +Auto-configured clients use a `SentryOkHttpInterceptor` with default options. To customize it (for example, with a `BeforeSpanCallback` or the `captureFailedRequests` options described below), add your own configured `SentryOkHttpInterceptor` to the bean. The auto-configuration keeps it and doesn't add a second one. Don't add a `SentryOkHttpEventListener` to a Spring-managed bean when this option is enabled, because the auto-configuration wraps the bean's event listener and would report each operation twice. + +Auto-configuration doesn't instrument clients created outside Spring or `OkHttpClient` subclasses. Configure these clients manually as shown below. + + + +Sentry skips auto-configuration when its OpenTelemetry agentless integration or Java Agent is on the classpath because OpenTelemetry already instruments OkHttp. + + + +### Configure Manually + +Add the Sentry interceptor and event listener when you create an OkHttp client that Spring doesn't manage. + + + + + +Add the Sentry interceptor and event listener when you create your `OkHttpClient` instance. + + ```kotlin import okhttp3.OkHttpClient From c56897e5b3ba046e1bb3baddcc8ceb112fb0d3a7 Mon Sep 17 00:00:00 2001 From: Lukas Bloder Date: Tue, 22 Sep 2026 14:50:36 +0200 Subject: [PATCH 2/2] update wording to reflect recent changes in code --- docs/platforms/java/common/tracing/instrumentation/okhttp.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/platforms/java/common/tracing/instrumentation/okhttp.mdx b/docs/platforms/java/common/tracing/instrumentation/okhttp.mdx index 58646db2a644e1..aaa0b78a1eec44 100644 --- a/docs/platforms/java/common/tracing/instrumentation/okhttp.mdx +++ b/docs/platforms/java/common/tracing/instrumentation/okhttp.mdx @@ -59,7 +59,7 @@ sentry: The auto-configuration preserves each client's existing configuration, interceptors, and event listeners. It adds the Sentry interceptor only once and doesn't create an `OkHttpClient` bean if your application hasn't defined one. -Auto-configured clients use a `SentryOkHttpInterceptor` with default options. To customize it (for example, with a `BeforeSpanCallback` or the `captureFailedRequests` options described below), add your own configured `SentryOkHttpInterceptor` to the bean. The auto-configuration keeps it and doesn't add a second one. Don't add a `SentryOkHttpEventListener` to a Spring-managed bean when this option is enabled, because the auto-configuration wraps the bean's event listener and would report each operation twice. +Auto-configured clients use a `SentryOkHttpInterceptor` and `SentryOkHttpEventListener` with default options. To customize them (for example, with a `BeforeSpanCallback`, the `captureFailedRequests` options, or a delegate `EventListener` as described below), add your own configured `SentryOkHttpInterceptor` or `SentryOkHttpEventListener` to the bean. The auto-configuration uses your instances instead of adding its own. Auto-configuration doesn't instrument clients created outside Spring or `OkHttpClient` subclasses. Configure these clients manually as shown below.