修改servername获取方式

parent 856982e3
......@@ -27,7 +27,6 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
......
......@@ -11,6 +11,7 @@ import brave.spring.web.TracingClientHttpRequestInterceptor;
import brave.spring.webmvc.DelegatingTracingFilter;
import brave.spring.webmvc.SpanCustomizingAsyncHandlerInterceptor;
import cn.quantgroup.tech.brave.properties.BraveProperties;
import cn.quantgroup.tech.brave.properties.ServiceProperties;
import cn.quantgroup.tech.brave.service.ITechRabbitBuilder;
import cn.quantgroup.tech.brave.service.TechRabbitBuilderNoTrace;
import cn.quantgroup.tech.brave.service.TechRabbitBuilderTrace;
......@@ -67,7 +68,6 @@ public class BraveAutoConfiguration {
}
@Configuration
@EnableWebMvc
@EnableConfigurationProperties( BraveProperties.class )
@ConditionalOnProperty( prefix = "tech.brave", name = "enabled", havingValue = "false" )
public static class BraveUntEnabled {
......@@ -117,13 +117,16 @@ public class BraveAutoConfiguration {
@Configuration
@EnableWebMvc
@EnableConfigurationProperties( BraveProperties.class )
@EnableConfigurationProperties( {BraveProperties.class, ServiceProperties.class} )
@ConditionalOnProperty( prefix = "tech.brave", name = "enabled", havingValue = "true" )
@Import( {TracingClientHttpRequestInterceptor.class, SpanCustomizingAsyncHandlerInterceptor.class} )
public static class BraveEnabled extends WebMvcConfigurerAdapter {
@Autowired
private BraveProperties braveProperties;
@Autowired
private ServiceProperties serviceProperties;
@Autowired
private TracingClientHttpRequestInterceptor clientInterceptor;
......@@ -145,7 +148,7 @@ public class BraveAutoConfiguration {
Tracing tracing() {
return Tracing.newBuilder()
.sampler(brave.sampler.Sampler.create(braveProperties.getSample()))
.localServiceName(braveProperties.getServiceName())
.localServiceName(serviceProperties.getName())
.propagationFactory(ExtraFieldPropagation.newFactory(B3Propagation.FACTORY, "user-name"))
.currentTraceContext(ThreadContextCurrentTraceContext.create())
.spanReporter(spanReporter()).build();
......
......@@ -12,20 +12,15 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
@Data
@ConfigurationProperties( prefix = "tech.brave" )
public class BraveProperties {
/**
* 指定serviceName
*/
private String serviceName = "brave";
/**
* kafka地址
*/
private String kafkaBootstrapServers = "172.30.220.11:16091,172.30.220.11:16092,172.30.220.11:16093";
private String kafkaBootstrapServers;
/**
* kafka的topic
*/
private String kafkaTopic = "quantGroup.tech.brave.dev";
private String kafkaTopic;
/**
* 采集率
......
package cn.quantgroup.tech.brave.properties;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
/**
* brave配置信息
*
* @author zhangheng
* create on 2018.04.25
*/
@Data
@ConfigurationProperties("spring.application")
public class ServiceProperties {
/**
*
*/
String name;
}
......@@ -96,12 +96,6 @@
<artifactId>assertj-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-sleuth-stream</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</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