File tree Expand file tree Collapse file tree 4 files changed +24
-8
lines changed
sentry-samples-spring-jakarta/src/main/java/io/sentry/samples/spring/jakarta
sentry-samples-spring/src/main/java/io/sentry/samples/spring Expand file tree Collapse file tree 4 files changed +24
-8
lines changed Original file line number Diff line number Diff line change 11package io .sentry .samples .spring .jakarta ;
22
3- import io .sentry .ScopesAdapter ;
3+ import io .sentry .IScopes ;
44import io .sentry .spring .jakarta .SentryUserFilter ;
55import io .sentry .spring .jakarta .SentryUserProvider ;
66import java .util .List ;
7+ import org .springframework .beans .factory .annotation .Autowired ;
8+ import org .springframework .context .ApplicationContext ;
79import org .springframework .context .annotation .Bean ;
810import org .springframework .context .annotation .Configuration ;
911import org .springframework .context .annotation .Import ;
1214@ Import (SentryConfig .class )
1315public class AppConfig {
1416
17+ @ Autowired private ApplicationContext applicationContext ;
18+
1519 @ Bean
1620 SentryUserFilter sentryUserFilter (final List <SentryUserProvider > sentryUserProviders ) {
17- return new SentryUserFilter (ScopesAdapter . getInstance ( ), sentryUserProviders );
21+ return new SentryUserFilter (applicationContext . getBean ( IScopes . class ), sentryUserProviders );
1822 }
1923}
Original file line number Diff line number Diff line change 11package io .sentry .samples .spring .jakarta ;
22
3- import io .sentry .ScopesAdapter ;
3+ import io .sentry .IScopes ;
44import io .sentry .spring .jakarta .tracing .SentrySpanClientHttpRequestInterceptor ;
55import java .util .Collections ;
6+ import org .springframework .beans .factory .annotation .Autowired ;
7+ import org .springframework .context .ApplicationContext ;
68import org .springframework .context .annotation .Bean ;
79import org .springframework .context .annotation .ComponentScan ;
810import org .springframework .context .annotation .Configuration ;
1618@ EnableWebMvc
1719public class WebConfig {
1820
21+ @ Autowired private ApplicationContext applicationContext ;
22+
1923 /**
2024 * Creates a {@link RestTemplate} which calls are intercepted with {@link
2125 * SentrySpanClientHttpRequestInterceptor} to create spans around HTTP calls.
@@ -26,7 +30,7 @@ public class WebConfig {
2630 RestTemplate restTemplate () {
2731 RestTemplate restTemplate = new RestTemplate ();
2832 SentrySpanClientHttpRequestInterceptor sentryRestTemplateInterceptor =
29- new SentrySpanClientHttpRequestInterceptor (ScopesAdapter . getInstance ( ));
33+ new SentrySpanClientHttpRequestInterceptor (applicationContext . getBean ( IScopes . class ));
3034 restTemplate .setInterceptors (Collections .singletonList (sentryRestTemplateInterceptor ));
3135 return restTemplate ;
3236 }
Original file line number Diff line number Diff line change 11package io .sentry .samples .spring ;
22
3- import io .sentry .ScopesAdapter ;
3+ import io .sentry .IScopes ;
44import io .sentry .spring .SentryUserFilter ;
55import io .sentry .spring .SentryUserProvider ;
66import java .util .List ;
7+ import org .springframework .beans .factory .annotation .Autowired ;
8+ import org .springframework .context .ApplicationContext ;
79import org .springframework .context .annotation .Bean ;
810import org .springframework .context .annotation .Configuration ;
911import org .springframework .context .annotation .Import ;
1214@ Import (SentryConfig .class )
1315public class AppConfig {
1416
17+ @ Autowired private ApplicationContext applicationContext ;
18+
1519 @ Bean
1620 SentryUserFilter sentryUserFilter (final List <SentryUserProvider > sentryUserProviders ) {
17- return new SentryUserFilter (ScopesAdapter . getInstance ( ), sentryUserProviders );
21+ return new SentryUserFilter (applicationContext . getBean ( IScopes . class ), sentryUserProviders );
1822 }
1923}
Original file line number Diff line number Diff line change 11package io .sentry .samples .spring ;
22
3- import io .sentry .ScopesAdapter ;
3+ import io .sentry .IScopes ;
44import io .sentry .spring .tracing .SentrySpanClientHttpRequestInterceptor ;
55import java .util .Collections ;
6+ import org .springframework .beans .factory .annotation .Autowired ;
7+ import org .springframework .context .ApplicationContext ;
68import org .springframework .context .annotation .Bean ;
79import org .springframework .context .annotation .ComponentScan ;
810import org .springframework .context .annotation .Configuration ;
1618@ EnableWebMvc
1719public class WebConfig {
1820
21+ @ Autowired private ApplicationContext applicationContext ;
22+
1923 /**
2024 * Creates a {@link RestTemplate} which calls are intercepted with {@link
2125 * SentrySpanClientHttpRequestInterceptor} to create spans around HTTP calls.
@@ -26,7 +30,7 @@ public class WebConfig {
2630 RestTemplate restTemplate () {
2731 RestTemplate restTemplate = new RestTemplate ();
2832 SentrySpanClientHttpRequestInterceptor sentryRestTemplateInterceptor =
29- new SentrySpanClientHttpRequestInterceptor (ScopesAdapter . getInstance ( ));
33+ new SentrySpanClientHttpRequestInterceptor (applicationContext . getBean ( IScopes . class ));
3034 restTemplate .setInterceptors (Collections .singletonList (sentryRestTemplateInterceptor ));
3135 return restTemplate ;
3236 }
You can’t perform that action at this time.
0 commit comments