|
|
|
|
@ -1,11 +1,7 @@
|
|
|
|
|
package cn.iocoder.yudao.framework.tracer.config;
|
|
|
|
|
|
|
|
|
|
import cn.iocoder.yudao.framework.common.enums.WebFilterOrderEnum;
|
|
|
|
|
import cn.iocoder.yudao.framework.tracer.core.aop.BizTraceAspect;
|
|
|
|
|
import cn.iocoder.yudao.framework.tracer.core.filter.TraceFilter;
|
|
|
|
|
import io.opentracing.Tracer;
|
|
|
|
|
import io.opentracing.util.GlobalTracer;
|
|
|
|
|
import org.apache.skywalking.apm.toolkit.opentracing.SkywalkingTracer;
|
|
|
|
|
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
|
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
|
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
|
|
|
|
@ -20,32 +16,28 @@ import org.springframework.context.annotation.Bean;
|
|
|
|
|
*/
|
|
|
|
|
@AutoConfiguration
|
|
|
|
|
@ConditionalOnClass(name = {
|
|
|
|
|
"org.apache.skywalking.apm.toolkit.opentracing.SkywalkingTracer",
|
|
|
|
|
"io.opentracing.Tracer",
|
|
|
|
|
"org.apache.skywalking.apm.toolkit.opentracing.SkywalkingTracer", // 来自 apm-toolkit-opentracing.jar
|
|
|
|
|
// "io.opentracing.Tracer", // 来自 opentracing-api.jar
|
|
|
|
|
"jakarta.servlet.Filter"
|
|
|
|
|
})
|
|
|
|
|
@EnableConfigurationProperties(TracerProperties.class)
|
|
|
|
|
@ConditionalOnProperty(prefix = "yudao.tracer", value = "enable", matchIfMissing = true)
|
|
|
|
|
public class YudaoTracerAutoConfiguration {
|
|
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
|
public TracerProperties bizTracerProperties() {
|
|
|
|
|
return new TracerProperties();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
|
public BizTraceAspect bizTracingAop() {
|
|
|
|
|
return new BizTraceAspect(tracer());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
|
public Tracer tracer() {
|
|
|
|
|
// 创建 SkywalkingTracer 对象
|
|
|
|
|
SkywalkingTracer tracer = new SkywalkingTracer();
|
|
|
|
|
// 设置为 GlobalTracer 的追踪器
|
|
|
|
|
GlobalTracer.registerIfAbsent(tracer);
|
|
|
|
|
return tracer;
|
|
|
|
|
}
|
|
|
|
|
// TODO @芋艿:skywalking 不兼容最新的 opentracing 版本。同时,opentracing 也停止了维护,尬住了!后续换 opentelemetry 即可!
|
|
|
|
|
// @Bean
|
|
|
|
|
// public BizTraceAspect bizTracingAop() {
|
|
|
|
|
// return new BizTraceAspect(tracer());
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// @Bean
|
|
|
|
|
// public Tracer tracer() {
|
|
|
|
|
// // 创建 SkywalkingTracer 对象
|
|
|
|
|
// SkywalkingTracer tracer = new SkywalkingTracer();
|
|
|
|
|
// // 设置为 GlobalTracer 的追踪器
|
|
|
|
|
// GlobalTracer.registerIfAbsent(tracer);
|
|
|
|
|
// return tracer;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 创建 TraceFilter 过滤器,响应 header 设置 traceId
|
|
|
|
|
|