Commit cb50dec9 authored by meng.cheng's avatar meng.cheng

清理无用代码

parent c6fa0339
...@@ -2,7 +2,6 @@ package cn.quantgroup.tech.brave.configuration; ...@@ -2,7 +2,6 @@ package cn.quantgroup.tech.brave.configuration;
import cn.quantgroup.tech.brave.interceptor.*; import cn.quantgroup.tech.brave.interceptor.*;
import cn.quantgroup.tech.brave.interceptor.impl.*; import cn.quantgroup.tech.brave.interceptor.impl.*;
import cn.quantgroup.tech.brave.job.TokenJob;
import okhttp3.Interceptor; import okhttp3.Interceptor;
import org.apache.http.HttpRequestInterceptor; import org.apache.http.HttpRequestInterceptor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
...@@ -89,10 +88,6 @@ public class AuthAutoConfiguration { ...@@ -89,10 +88,6 @@ public class AuthAutoConfiguration {
} }
} }
@Bean
@ConditionalOnProperty(prefix = "tech.auth", name = {"http", "clientId", "secret", "tokenUrl"})
public TokenJob tokenJob() {
return new TokenJob();
}
} }
} }
...@@ -192,257 +192,6 @@ public class BraveAutoConfiguration { ...@@ -192,257 +192,6 @@ public class BraveAutoConfiguration {
} }
} }
@Configuration
@EnableConfigurationProperties({BraveProperties.class, ServiceProperties.class})
@ConditionalOnProperty(prefix = "tech.brave", name = "enabled", havingValue = "true", matchIfMissing = true)
public static class BraveEnabled {
@Autowired
private BraveProperties braveProperties;
@Autowired
private ServiceProperties serviceProperties;
@Bean
@ConditionalOnMissingBean
Sender sender() {
return KafkaSender.newBuilder().bootstrapServers(braveProperties.getKafkaBootstrapServers()).topic(braveProperties.getKafkaTopic()).encoding(Encoding.JSON).build();
}
@Bean
@ConditionalOnMissingBean
AsyncReporter<Span> spanReporter() {
return AsyncReporter.create(sender());
}
@Bean
@ConditionalOnMissingBean
Tracing tracing() {
return Tracing.newBuilder()
.sampler(brave.sampler.Sampler.create(braveProperties.getSample()))
.localServiceName(serviceProperties.getName())
.propagationFactory(ExtraFieldPropagation.newFactory(B3Propagation.FACTORY, "user-name"))
.currentTraceContext(MDCCurrentTraceContext.create())
.spanReporter(spanReporter()).build();
}
@Deprecated
@Bean
@ConditionalOnMissingBean
public HttpTracing httpTracing(Tracing tracing) {
return HttpTracing.create(tracing);
}
@Configuration
@ConditionalOnWebApplication
@ConditionalOnClass({Filter.class})
@ConditionalOnProperty(prefix = "tech.brave", name = "enabled", havingValue = "true", matchIfMissing = true)
public static class ServletEnable {
@Bean
public FilterRegistrationBean registrationBean() {
FilterRegistrationBean registrationBean = new FilterRegistrationBean();
CustomDelegatingTracingFilter delegatingTracingFilter = new CustomDelegatingTracingFilter();
registrationBean.setFilter(delegatingTracingFilter);
registrationBean.setName("techDelegatingTracingFilter");
registrationBean.setOrder(Integer.MIN_VALUE);
registrationBean.addUrlPatterns("/*");
return registrationBean;
}
}
@Configuration
@ConditionalOnClass({WebMvcConfigurerAdapter.class})
@Import(SpanCustomizingAsyncHandlerInterceptor.class)
@ConditionalOnProperty(prefix = "tech.brave", name = "enabled", havingValue = "true", matchIfMissing = true)
public static class WebMvcEnable extends WebMvcConfigurerAdapter {
@Autowired
private SpanCustomizingAsyncHandlerInterceptor spanCustomizingAsyncHandlerInterceptor;
@Override
public void addInterceptors(InterceptorRegistry registry) {
log.info("添加braveWebmvc拦截器");
registry.addInterceptor(spanCustomizingAsyncHandlerInterceptor);
}
}
@Configuration
@ConditionalOnClass(RabbitTemplate.class)
@ConditionalOnProperty(prefix = "tech.brave", name = "enabled", havingValue = "true", matchIfMissing = true)
public static class RabbitTemplateEnable {
/**
* 提供RabbitTemplateBuilder,业务系统需要使用该Builder生成RabbitTemplate
*
* @param tracing
* @return
*/
@Bean(name = "techRabbitBuilder")
public ITechRabbitBuilder rabbitTemplateBuilder(Tracing tracing) {
return new TechRabbitBuilderTrace(tracing);
}
}
@Deprecated
@Configuration
@ConditionalOnClass(HttpClient.class)
@ConditionalOnProperty(prefix = "tech.brave", name = "enabled", havingValue = "true", matchIfMissing = true)
public static class HttpClientEnable {
/**
* 提供HttpClientBuilderBean
*
* @param tracing
* @return
* @see ITechHttpClient
*/
@Deprecated
@Bean(name = "techHttpClientBuilder")
public HttpClientBuilder httpClientBuilder(Tracing tracing) {
log.info("注册braveHttpClientBuilder");
return TracingHttpClientBuilder.create(tracing);
}
}
@Deprecated
@Configuration
@ConditionalOnClass(OkHttpClient.class)
@ConditionalOnProperty(prefix = "tech.brave", name = "enabled", havingValue = "true", matchIfMissing = true)
public static class OkHttpClientEnable {
/**
* 提供OkHttpClientBean
*
* @param httpTracing
* @return
* @see ITechOkHttpClient
*/
@Deprecated
@Bean(name = "techOkHttpClientBuilder")
public OkHttpClient.Builder okHttpClientBuilder(HttpTracing httpTracing) {
log.info("注册braveOkHttpClient.Builder");
return new OkHttpClient.Builder()
.dispatcher(new Dispatcher(httpTracing.tracing().currentTraceContext().executorService(new Dispatcher().executorService())))
.addNetworkInterceptor(TracingInterceptor.create(httpTracing));
}
}
@Deprecated
@Configuration
@ConditionalOnClass(RestTemplate.class)
@ConditionalOnProperty(prefix = "tech.brave", name = "enabled", havingValue = "true", matchIfMissing = true)
@Import(TracingClientHttpRequestInterceptor.class)
public static class RestTemplateEnable {
@Autowired
private TracingClientHttpRequestInterceptor clientInterceptor;
/**
* 提供RestTemplate
*
* @return
* @see ITechRestTemplateBuilder
*/
@Deprecated
@Bean(name = "techRestTemplate")
public RestTemplate restTemplate() {
log.info("添加braveRestTemplate拦截器");
RestTemplate restTemplate = new RestTemplate();
List<ClientHttpRequestInterceptor> interceptors =
new ArrayList<>(restTemplate.getInterceptors());
interceptors.add(clientInterceptor);
restTemplate.setInterceptors(interceptors);
return restTemplate;
}
}
@Configuration
@ConditionalOnClass(HttpClient.class)
@ConditionalOnProperty(prefix = "tech.brave", name = "enabled", havingValue = "true", matchIfMissing = true)
public static class TechHttpClientEnable {
/**
* 提供TechHttpClientBuilder
*
* @param tracing
* @return
*/
@Bean(name = "techHttpClient")
public ITechHttpClient techHttpClient(Tracing tracing) {
log.info("注册ITechHttpClient, 已开启brave");
return new TechHttpClientTrace(tracing);
}
}
@Configuration
@ConditionalOnClass(OkHttpClient.class)
@ConditionalOnProperty(prefix = "tech.brave", name = "enabled", havingValue = "true", matchIfMissing = true)
public static class TechOkHttpClientEnable {
/**
* 提供TechOkHttpClient
*
* @param tracing
* @return
*/
@Bean(name = "techOkHttpClient")
public ITechOkHttpClient techOkHttpClient(Tracing tracing) {
log.info("注册ITechOkHttpClient, 已开启brave");
return new TechOkHttpClientTrace(tracing);
}
}
@Configuration
@ConditionalOnClass(RestTemplate.class)
@ConditionalOnProperty(prefix = "tech.brave", name = "enabled", havingValue = "true", matchIfMissing = true)
@Import(TracingClientHttpRequestInterceptor.class)
public static class TechRestTemplateEnable {
/**
* 提供RestTemplate
*
* @return
*/
@Bean(name = "techRestTemplateBuilder")
public ITechRestTemplateBuilder techRestTemplateBuilder() {
return new TechRestTemplateBuilderTrace();
}
}
@Configuration
@ConditionalOnProperty(prefix = "tech.brave", name = "enabled", havingValue = "true", matchIfMissing = true)
public static class TechExecutorServiceEnable {
@Bean(name = "techExecutorServiceBuilder")
public ITechExecutorServiceBuilder techExecutorServiceBuilder() {
return new TechExecutorServiceBuilderTrace();
}
}
@Aspect
@Configuration
@ConditionalOnClass(ElasticJob.class)
@ConditionalOnProperty(prefix = "tech.brave", name = "enabled", havingValue = "true", matchIfMissing = true)
public class ElasticJobAspect {
@Around("target(com.dangdang.ddframe.job.api.ElasticJob)")
public Object dynamicTrace(ProceedingJoinPoint pjp) throws Throwable {
Tracer tracer = tracing().tracer();
/* 防止应用层非法使用(上下文中存在span),不生成root span。 */
if (tracer.currentSpan() != null) {
return pjp.proceed();
}
brave.Span span = tracer.newTrace();
try (Tracer.SpanInScope ws = tracer.withSpanInScope(span)) {
// note: try-with-resources closes the scope *before* the catch block
return pjp.proceed();
} catch (RuntimeException | Error e) {
span.error(e);
throw e;
} finally {
span.finish();
}
}
}
}
} }
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
<lombok.version>1.16.20</lombok.version> <lombok.version>1.16.20</lombok.version>
<guava.version>23.0</guava.version> <guava.version>23.0</guava.version>
<apollo.client.version>0.10.2</apollo.client.version> <apollo.client.version>0.10.2</apollo.client.version>
<common.parent.version>0.3.2</common.parent.version> <common.parent.version>0.4.0</common.parent.version>
</properties> </properties>
<dependencies> <dependencies>
...@@ -91,11 +91,11 @@ ...@@ -91,11 +91,11 @@
<artifactId>idgenerator-spring-boot-starter</artifactId> <artifactId>idgenerator-spring-boot-starter</artifactId>
<version>${common.parent.version}</version> <version>${common.parent.version}</version>
</dependency> </dependency>
<dependency> <!-- <dependency>
<groupId>cn.quantgroup</groupId> <groupId>cn.quantgroup</groupId>
<artifactId>enoch-agent-spring-boot-starter</artifactId> <artifactId>enoch-agent-spring-boot-starter</artifactId>
<version>${common.parent.version}</version> <version>${common.parent.version}</version>
</dependency> </dependency>-->
<dependency> <dependency>
<groupId>cn.quantgroup</groupId> <groupId>cn.quantgroup</groupId>
<artifactId>elastic-job-lite-spring-boot-starter</artifactId> <artifactId>elastic-job-lite-spring-boot-starter</artifactId>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment