sofastack / sofa-tracer

SOFATracer is a component for the distributed system call trace. And through a unified traceId logging the logs of various network calls in the invoking link. These logs can be used for quick discovery of faults, service governance, etc.
Apache License 2.0
1.1k stars 371 forks source link

源代码很多配置类注解上很多@ComponentScan导致默认的配置无法去除,无法自定义配置 #71

Closed zzps closed 5 years ago

zzps commented 5 years ago

Describe the bug

根据自己业务需要在配置zipkin时需要使用自定义的配置类,但是源码中很多@ComponentScan导致使用了一个默认的配置后就将其他符合条件的配置全激活了,即使我使用springboot技术将源码的自动化配置去掉还是无用 A clear and concise description of what the bug is.

Expected behavior

Actual behavior

Steps to reproduce

Minimal yet complete reproducer code (or GitHub URL to code)

@Configuration @EnableConfigurationProperties(SofaTracerProperties.class) @ComponentScan(value = { "com.alipay.sofa.tracer.boot" }) public class SofaTracerAutoConfiguration { -----------省略 }

Environment

QilongZhang commented 5 years ago

@zzps 能否具体下配置的问题,我看是否能提供给你一个workaround的方式

QilongZhang commented 5 years ago

https://docs.spring.io/spring-boot/docs/1.5.15.RELEASE/reference/html/boot-features-developing-auto-configuration.html#boot-features-locating-auto-configuration-candidates

Auto-configurations have to be loaded that way only. Make sure that they are defined in a specific package space and that they are never the target of component scan in particular.

zzps commented 5 years ago

@QilongZhang 同学你好,我一共给你们提了两个issue: 1:你们的依赖zipkin-reporter按照你们github文档上的版本是错误的,导致找不到,这应该是文档问题,因为我在:www.sofastack.tech/sofa-tracer/docs/ReportToZipkin上看到的是另一个。 2:第二个issue我认为应该是你们将tracer开源出来没有将和你们自己业务契合的注解去掉的缘故。而且我觉得你们也是有必要把这个问题解决掉的,因为我在把你们最新的开发版本:2.2.0-SNAPSHOT拉下来看了也还是没有去掉,所以我自己修改了源码用的目前。 我再给你描述下这个问题吧: tracer-sofa-boot-starter 这个依赖中配置有 SofaTracerAutoConfiguration.class,OpenTracingSpringMvcAutoConfiguration.class,ZipkinSofaTracerAutoConfiguration.class三个自动配置类,其中前两个自动配置类上都有@componentscan扫描tracer的包路径,这样就 导致我只要启用了前两个自动配置类中的任何一个后,就算我怎样自定义配置自己的配置类或者将其余的自动配置去掉,其余的配置还是会被加载因为被@componentscan扫描了,这是不合逻辑的。而我根据我的业务确实需要做一些定制化的配置需要进行一些改造而不可得

QilongZhang commented 5 years ago

@zzps 感谢反馈哈,已经在 https://github.com/alipay/sofa-tracer/pull/72 修复这个问题了。