提交 | 用户 | 时间
|
e7c126
|
1 |
package com.iailab.framework.tracer.config; |
H |
2 |
|
|
3 |
import com.iailab.framework.common.enums.WebFilterOrderEnum; |
|
4 |
import com.iailab.framework.tracer.core.aop.BizTraceAspect; |
|
5 |
import com.iailab.framework.tracer.core.filter.TraceFilter; |
|
6 |
import org.springframework.boot.autoconfigure.AutoConfiguration; |
|
7 |
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; |
|
8 |
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; |
|
9 |
import org.springframework.boot.context.properties.EnableConfigurationProperties; |
|
10 |
import org.springframework.boot.web.servlet.FilterRegistrationBean; |
|
11 |
import org.springframework.context.annotation.Bean; |
|
12 |
|
|
13 |
/** |
|
14 |
* Tracer 配置类 |
|
15 |
* |
|
16 |
* @author mashu |
|
17 |
*/ |
|
18 |
@AutoConfiguration |
|
19 |
@ConditionalOnClass({BizTraceAspect.class}) |
|
20 |
@EnableConfigurationProperties(TracerProperties.class) |
|
21 |
@ConditionalOnProperty(prefix = "iailab.tracer", value = "enable", matchIfMissing = true) |
|
22 |
public class IailabTracerAutoConfiguration { |
|
23 |
|
|
24 |
// TODO @iailab:重要。目前 opentracing 版本存在冲突,要么保证 skywalking,要么保证阿里云短信 sdk |
|
25 |
// @Bean |
|
26 |
// public TracerProperties bizTracerProperties() { |
|
27 |
// return new TracerProperties(); |
|
28 |
// } |
|
29 |
// |
|
30 |
// @Bean |
|
31 |
// public BizTraceAspect bizTracingAop() { |
|
32 |
// return new BizTraceAspect(tracer()); |
|
33 |
// } |
|
34 |
// |
|
35 |
// @Bean |
|
36 |
// public Tracer tracer() { |
|
37 |
// // 创建 SkywalkingTracer 对象 |
|
38 |
// SkywalkingTracer tracer = new SkywalkingTracer(); |
|
39 |
// // 设置为 GlobalTracer 的追踪器 |
|
40 |
// GlobalTracer.register(tracer); |
|
41 |
// return tracer; |
|
42 |
// } |
|
43 |
|
|
44 |
/** |
|
45 |
* 创建 TraceFilter 过滤器,响应 header 设置 traceId |
|
46 |
*/ |
|
47 |
@Bean |
|
48 |
public FilterRegistrationBean<TraceFilter> traceFilter() { |
|
49 |
FilterRegistrationBean<TraceFilter> registrationBean = new FilterRegistrationBean<>(); |
|
50 |
registrationBean.setFilter(new TraceFilter()); |
|
51 |
registrationBean.setOrder(WebFilterOrderEnum.TRACE_FILTER); |
|
52 |
return registrationBean; |
|
53 |
} |
|
54 |
|
|
55 |
} |