Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import io.sentry.spring.jakarta.SentryUserFilter;
import io.sentry.spring.jakarta.SentryUserProvider;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
Expand All @@ -12,9 +14,10 @@
@Import(SentryConfig.class)
public class AppConfig {

@Autowired private ApplicationContext applicationContext;

@Bean
SentryUserFilter sentryUserFilter(
final IScopes scopes, final List<SentryUserProvider> sentryUserProviders) {
return new SentryUserFilter(scopes, sentryUserProviders);
SentryUserFilter sentryUserFilter(final List<SentryUserProvider> sentryUserProviders) {
return new SentryUserFilter(applicationContext.getBean(IScopes.class), sentryUserProviders);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import io.sentry.IScopes;
import io.sentry.spring.jakarta.tracing.SentrySpanClientHttpRequestInterceptor;
import java.util.Collections;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
Expand All @@ -16,18 +18,19 @@
@EnableWebMvc
public class WebConfig {

@Autowired private ApplicationContext applicationContext;

/**
* Creates a {@link RestTemplate} which calls are intercepted with {@link
* SentrySpanClientHttpRequestInterceptor} to create spans around HTTP calls.
*
* @param scopes - sentry scopes
* @return RestTemplate
*/
@Bean
RestTemplate restTemplate(IScopes scopes) {
RestTemplate restTemplate() {
RestTemplate restTemplate = new RestTemplate();
SentrySpanClientHttpRequestInterceptor sentryRestTemplateInterceptor =
new SentrySpanClientHttpRequestInterceptor(scopes);
new SentrySpanClientHttpRequestInterceptor(applicationContext.getBean(IScopes.class));
restTemplate.setInterceptors(Collections.singletonList(sentryRestTemplateInterceptor));
return restTemplate;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import io.sentry.spring.SentryUserFilter;
import io.sentry.spring.SentryUserProvider;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
Expand All @@ -12,9 +14,10 @@
@Import(SentryConfig.class)
public class AppConfig {

@Autowired private ApplicationContext applicationContext;

@Bean
SentryUserFilter sentryUserFilter(
final IScopes scopes, final List<SentryUserProvider> sentryUserProviders) {
return new SentryUserFilter(scopes, sentryUserProviders);
SentryUserFilter sentryUserFilter(final List<SentryUserProvider> sentryUserProviders) {
return new SentryUserFilter(applicationContext.getBean(IScopes.class), sentryUserProviders);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import io.sentry.IScopes;
import io.sentry.spring.tracing.SentrySpanClientHttpRequestInterceptor;
import java.util.Collections;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
Expand All @@ -16,18 +18,19 @@
@EnableWebMvc
public class WebConfig {

@Autowired private ApplicationContext applicationContext;

/**
* Creates a {@link RestTemplate} which calls are intercepted with {@link
* SentrySpanClientHttpRequestInterceptor} to create spans around HTTP calls.
*
* @param scopes - sentry scopes
* @return RestTemplate
*/
@Bean
RestTemplate restTemplate(IScopes scopes) {
RestTemplate restTemplate() {
RestTemplate restTemplate = new RestTemplate();
SentrySpanClientHttpRequestInterceptor sentryRestTemplateInterceptor =
new SentrySpanClientHttpRequestInterceptor(scopes);
new SentrySpanClientHttpRequestInterceptor(applicationContext.getBean(IScopes.class));
restTemplate.setInterceptors(Collections.singletonList(sentryRestTemplateInterceptor));
return restTemplate;
}
Expand Down
Loading