-
-
Notifications
You must be signed in to change notification settings - Fork 469
Expand file tree
/
Copy pathWebConfig.java
More file actions
34 lines (31 loc) · 1.25 KB
/
WebConfig.java
File metadata and controls
34 lines (31 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package io.sentry.samples.spring7;
import io.sentry.IScopes;
import io.sentry.spring7.tracing.SentrySpanClientHttpRequestInterceptor;
import java.util.Collections;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
@Configuration
@EnableAspectJAutoProxy(proxyTargetClass = true)
@ComponentScan("io.sentry.samples.spring7")
@EnableWebMvc
public class WebConfig {
/**
* 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 = new RestTemplate();
SentrySpanClientHttpRequestInterceptor sentryRestTemplateInterceptor =
new SentrySpanClientHttpRequestInterceptor(scopes);
restTemplate.setInterceptors(Collections.singletonList(sentryRestTemplateInterceptor));
return restTemplate;
}
}