-
-
Notifications
You must be signed in to change notification settings - Fork 468
Expand file tree
/
Copy pathWebConfig.java
More file actions
33 lines (30 loc) · 1.23 KB
/
WebConfig.java
File metadata and controls
33 lines (30 loc) · 1.23 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
package io.sentry.samples.spring;
import io.sentry.ScopesAdapter;
import io.sentry.spring.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.spring.web")
@EnableWebMvc
public class WebConfig {
/**
* Creates a {@link RestTemplate} which calls are intercepted with {@link
* SentrySpanClientHttpRequestInterceptor} to create spans around HTTP calls.
*
* @return RestTemplate
*/
@Bean
RestTemplate restTemplate() {
RestTemplate restTemplate = new RestTemplate();
SentrySpanClientHttpRequestInterceptor sentryRestTemplateInterceptor =
new SentrySpanClientHttpRequestInterceptor(ScopesAdapter.getInstance());
restTemplate.setInterceptors(Collections.singletonList(sentryRestTemplateInterceptor));
return restTemplate;
}
}