我们最近设置了一个jaeger服务器,以便跟踪整个系统中的所有请求。最初的设置工作得很好,只需在构建文件中添加必要的spring(云(启动器依赖项。每次,一个请求到达我们的一台服务器,就会创建一个新的跨度,并报告给使用一体式docker映像设置的jaeger服务器。
最重要的依赖项如下:
compile "org.springframework.boot:spring-boot-starter-web"
compile "org.springframework.boot:spring-boot-starter-actuator"
compile "org.springframework.boot:spring-boot-starter-undertow"
compile "org.springframework.boot:spring-boot-starter-aop"
compile "org.springframework.cloud:spring-cloud-starter-netflix-hystrix:2.0.2.RELEASE"
compile "org.springframework.cloud:spring-cloud-starter-openfeign:2.0.2.RELEASE"
compile "io.opentracing.contrib:opentracing-spring-cloud-feign-starter:0.2.1"
compile "io.opentracing.contrib:opentracing-spring-jaeger-cloud-starter:0.2.1"
compile "io.opentracing.contrib:opentracing-spring-jaeger-starter:0.2.1"
compile "io.opentracing.contrib:opentracing-spring-web-autoconfigure:0.2.1"
在服务器上创建跨度时,所需的标头不会转发到外部客户端。根据文档,添加opentraceing spring-cloud foreign starter依赖关系应该是成功的,但到目前为止,没有一个foreign客户端工作。
我还为opentraceing 提供的自动配置类添加了一个断点
@Bean
FeignContextBeanPostProcessor feignContextBeanPostProcessor(BeanFactory beanFactory) {
return new FeignContextBeanPostProcessor(tracer, beanFactory, spanDecorators);
}
并且在应用程序启动时调用此方法。日志中也有一些关于jaeger/opentracking初始化的信息:
main 22:26:53.371 3222 INFO o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker - Bean 'io.opentracing.contrib.spring.cloud.async.DefaultAsyncAutoConfiguration$DefaultTracedAsyncConfigurerSupport' of type [io.opentracing.contrib.spring.cloud.async.DefaultAsyncAutoConfiguration$DefaultTracedAsyncConfigurerSupport$$EnhancerBySpringCGLIB$$4ab0858a] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
main 22:26:53.478 3329 INFO o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker - Bean 'io.opentracing.contrib.spring.cloud.async.DefaultAsyncAutoConfiguration' of type [io.opentracing.contrib.spring.cloud.async.DefaultAsyncAutoConfiguration$$EnhancerBySpringCGLIB$$4bce5627] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
main 22:26:53.670 3521 INFO o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker - Bean 'io.opentracing.contrib.spring.cloud.feign.FeignTracingAutoConfiguration' of type [io.opentracing.contrib.spring.cloud.feign.FeignTracingAutoConfiguration$$EnhancerBySpringCGLIB$$3a2361a6] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
main 22:26:53.905 3756 INFO o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker - Bean 'io.opentracing.contrib.java.spring.jaeger.starter.JaegerAutoConfiguration' of type [io.opentracing.contrib.java.spring.jaeger.starter.JaegerAutoConfiguration$$EnhancerBySpringCGLIB$$5c956416] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
main 22:26:53.942 3793 INFO o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker - Bean 'opentracing.jaeger-io.opentracing.contrib.java.spring.jaeger.starter.JaegerConfigurationProperties' of type [io.opentracing.contrib.java.spring.jaeger.starter.JaegerConfigurationProperties] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
main 22:26:53.962 3813 INFO o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker - Bean 'metricsFactory' of type [io.jaegertracing.internal.metrics.NoopMetricsFactory] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
main 22:26:53.977 3828 INFO o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker - Bean 'reporterMetrics' of type [io.jaegertracing.internal.metrics.Metrics] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
main 22:26:53.982 3833 INFO o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker - Bean 'sampler' of type [io.jaegertracing.internal.samplers.ConstSampler] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
main 22:26:54.013 3864 INFO o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker - Bean 'reporter' of type [io.jaegertracing.internal.reporters.CompositeReporter] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
main 22:26:54.028 3879 INFO o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker - Bean 'tracer' of type [io.jaegertracing.internal.JaegerTracer] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
main 22:26:59.495 9346 INFO o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker - Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$216245cc] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
我花了相当长的时间阅读文档,并寻找如何正确配置spring-boot/cloud应用程序以便与外国客户机合作的示例,但到目前为止我运气不佳。大多数示例都使用Springs的RestTemplate而不是Feign客户端。
如果有人能为我指明正确的方向,我会非常高兴。
发现Feign客户端当前不受支持,或者确切地说,spring-startes没有相应地配置Feign客户端。如果你想在你的Feign客户中使用Jaeger,你必须提供自己的集成。
根据我目前的经验,jaeger社区的支持度较低,因此你必须自己获得这些知识,在我看来,这是一个很大的不利因素,你可能应该考虑使用替代方案。
在某些情况下,可能需要在Spring配置中显式公开Feign客户端,以便传播traceId。这可以通过将以下内容添加到您的配置类中轻松完成
@Bean
public Client feignClient() {
return new Client.Default(null, null);
}