Skip to content

Commit 95ad517

Browse files
authored
fix(java): fix RestTemplate auto-instrumentation guide (#13236)
* fix(java): fix `RestTemplate` autoinstrumentation guide * Update automatic-instrumentation.mdx * Update automatic-instrumentation.mdx
1 parent 6f44215 commit 95ad517

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

docs/platforms/java/guides/spring/tracing/instrumentation/automatic-instrumentation.mdx

+12-12
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Each sampled request executed by this controller method will be turned into a tr
5151
Sentry Spring integration provides `SentrySpanClientHttpRequestInterceptor` that creates a span for each outgoing HTTP request executed with a `RestTemplate`. To use instrumented `RestTemplate` make sure to set interceptor on the `RestTemplate` bean:
5252

5353
```java {tabTitle:Java (Spring 5)}
54-
import io.sentry.IHub;
54+
import io.sentry.IScopes;
5555
import io.sentry.spring.tracing.SentrySpanClientHttpRequestInterceptor;
5656
import java.util.Collections;
5757
import org.springframework.context.annotation.Bean;
@@ -63,18 +63,18 @@ import org.springframework.web.util.UriTemplateHandler;
6363
class AppConfig {
6464

6565
@Bean
66-
RestTemplate restTemplate(IHub hub) {
66+
RestTemplate restTemplate(IScopes scopes) {
6767
RestTemplate restTemplate = new RestTemplate();
6868
SentrySpanClientHttpRequestInterceptor sentryRestTemplateInterceptor =
69-
new SentrySpanClientHttpRequestInterceptor(hub);
69+
new SentrySpanClientHttpRequestInterceptor(scopes);
7070
restTemplate.setInterceptors(Collections.singletonList(sentryRestTemplateInterceptor));
7171
return restTemplate;
7272
}
7373
}
7474
```
7575

7676
```java {tabTitle:Java (Spring 6)}
77-
import io.sentry.IHub;
77+
import io.sentry.IScopes;
7878
import io.sentry.spring.jakarta.tracing.SentrySpanClientHttpRequestInterceptor;
7979
import java.util.Collections;
8080
import org.springframework.context.annotation.Bean;
@@ -86,18 +86,18 @@ import org.springframework.web.util.UriTemplateHandler;
8686
class AppConfig {
8787

8888
@Bean
89-
RestTemplate restTemplate(IHub hub) {
89+
RestTemplate restTemplate(IScopes scopes) {
9090
RestTemplate restTemplate = new RestTemplate();
9191
SentrySpanClientHttpRequestInterceptor sentryRestTemplateInterceptor =
92-
new SentrySpanClientHttpRequestInterceptor(hub);
92+
new SentrySpanClientHttpRequestInterceptor(scopes);
9393
restTemplate.setInterceptors(Collections.singletonList(sentryRestTemplateInterceptor));
9494
return restTemplate;
9595
}
9696
}
9797
```
9898

9999
```kotlin {tabTitle:Kotlin (Spring 5)}
100-
import io.sentry.IHub
100+
import io.sentry.IScopes
101101
import io.sentry.spring.tracing.SentrySpanClientHttpRequestInterceptor
102102
import org.springframework.context.annotation.Bean
103103
import org.springframework.context.annotation.Configuration
@@ -108,8 +108,8 @@ import org.springframework.web.util.UriTemplateHandler
108108
class AppConfig {
109109

110110
@Bean
111-
fun restTemplate(hub: IHub): RestTemplate {
112-
val sentryRestTemplateInterceptor = SentrySpanClientHttpRequestInterceptor(hub)
111+
fun restTemplate(scopes: IScopes): RestTemplate {
112+
val sentryRestTemplateInterceptor = SentrySpanClientHttpRequestInterceptor(scopes)
113113

114114
return RestTemplate().apply {
115115
interceptors = listOf(sentryRestTemplateInterceptor)
@@ -119,7 +119,7 @@ class AppConfig {
119119
```
120120

121121
```kotlin {tabTitle:Kotlin (Spring 6)}
122-
import io.sentry.IHub
122+
import io.sentry.IScopes
123123
import io.sentry.spring.jakarta.tracing.SentrySpanClientHttpRequestInterceptor
124124
import org.springframework.context.annotation.Bean
125125
import org.springframework.context.annotation.Configuration
@@ -130,8 +130,8 @@ import org.springframework.web.util.UriTemplateHandler
130130
class AppConfig {
131131

132132
@Bean
133-
fun restTemplate(hub: IHub): RestTemplate {
134-
val sentryRestTemplateInterceptor = SentrySpanClientHttpRequestInterceptor(hub)
133+
fun restTemplate(scopes: IScopes): RestTemplate {
134+
val sentryRestTemplateInterceptor = SentrySpanClientHttpRequestInterceptor(scopes)
135135

136136
return RestTemplate().apply {
137137
interceptors = listOf(sentryRestTemplateInterceptor)

0 commit comments

Comments
 (0)