gpt4 book ai didi

spring-cloud-netflix - ZipkinSpanReporter 无法正常工作

转载 作者:行者123 更新时间:2023-12-04 03:08:34 24 4
gpt4 key购买 nike

我正在尝试评估 zipkin,以便为我们所有的微服务启用分布式跟踪功能。以下是我设置中的版本。

  1. Spring-boot 版本:1.5.7.RELEASE

  2. spring-cloud 版本:卡姆登.SR6

  3. zipkin 版本:2.2.1

    application.properties 中 seluth 的配置

spring.sleuth.sampler.percentage=1.0

spring.sleuth.web.skipPattern=(^cleanup.|.+favicon.)

然后我创建了 ZipkinSpanReporter bean,如下所示。请注意,我已将 Eureka 服务器设置为所有微服务,甚至是向 Eureka 服务器注册的 zipkin 服务器,以便 Zipkin 客户端可以通过 eureka 解析 zipkin 服务器

 @Bean
public ZipkinSpanReporter makeZipkinSpanReporter() {
return new ZipkinSpanReporter() {
private HttpZipkinSpanReporter delegate;
private String baseUrl;

@Override
public void report(Span span) {

InstanceInfo instance = eurekaClient
.getNextServerFromEureka("zipkin", false);
if (!(baseUrl != null &&
instance.getHomePageUrl().equals(baseUrl))) {
baseUrl = instance.getHomePageUrl();
delegate = new HttpZipkinSpanReporter(baseUrl,
zipkinProperties.getFlushInterval(),
zipkinProperties.getCompression().isEnabled(),
spanMetricReporter);

if (!span.name.matches(skipPattern)) delegate.report(span);
}
}
};
}

我观察到的是,当我检查 zipkin 时,zipkin 客户端(书籍)没有将所有跨度报告回 zipkin 服务器。报告了一些,几乎所有跨度都被删除了

enter image description here

我已经为

启用了日志记录
logging.level.org.springframework.cloud.sleuth.instrument.web=DEBUG
logging.file=book.log

下面是日志信息:

2017-10-30 12:51:41.747 DEBUG [book,73fdabf29eb273f2,73fdabf29eb273f2,true] 14088 --- [http-nio-8888-exec-1] o.s.c.sleuth.instrument.web.TraceFilter  : No parent span present - creating a new span
2017-10-30 12:51:41.749 DEBUG [book,73fdabf29eb273f2,73fdabf29eb273f2,true] 14088 --- [http-nio-8888-exec-1] o.s.c.s.i.web.TraceHandlerInterceptor : Handling span [Trace: 73fdabf29eb273f2, Span: 73fdabf29eb273f2, Parent: null, exportable:true]
2017-10-30 12:51:41.750 DEBUG [book,73fdabf29eb273f2,73fdabf29eb273f2,true] 14088 --- [http-nio-8888-exec-1] o.s.c.s.i.web.TraceHandlerInterceptor : Adding a method tag with value [checkedOut] to a span [Trace: 73fdabf29eb273f2, Span: 73fdabf29eb273f2, Parent: null, exportable:true]
2017-10-30 12:51:41.750 DEBUG [book,73fdabf29eb273f2,73fdabf29eb273f2,true] 14088 --- [http-nio-8888-exec-1] o.s.c.s.i.web.TraceHandlerInterceptor : Adding a class tag with value [BookApplication] to a span [Trace: 73fdabf29eb273f2, Span: 73fdabf29eb273f2, Parent: null, exportable:true]
2017-10-30 12:51:41.752 DEBUG [book,73fdabf29eb273f2,73fdabf29eb273f2,true] 14088 --- [http-nio-8888-exec-1] o.s.c.sleuth.instrument.web.TraceFilter : Closing the span [Trace: 73fdabf29eb273f2, Span: 73fdabf29eb273f2, Parent: null, exportable:true] since the response was successful
2017-10-30 12:51:42.133 DEBUG [book,,,] 14088 --- [http-nio-8888-exec-1] o.s.c.sleuth.instrument.web.TraceFilter : Received a request to uri [/favicon.ico] that should not be sampled [true]
2017-10-30 12:51:42.134 DEBUG [book,9e7aab2fdb2313a9,9e7aab2fdb2313a9,false] 14088 --- [http-nio-8888-exec-1] o.s.c.sleuth.instrument.web.TraceFilter : No parent span present - creating a new span
2017-10-30 12:51:42.142 DEBUG [book,9e7aab2fdb2313a9,9e7aab2fdb2313a9,false] 14088 --- [http-nio-8888-exec-1] o.s.c.sleuth.instrument.web.TraceFilter : Closing the span [Trace: 9e7aab2fdb2313a9, Span: 9e7aab2fdb2313a9, Parent: null, exportable:false] since the response was successful
2017-10-30 12:52:05.167 DEBUG [book,,,] 14088 --- [http-nio-8888-exec-2] o.s.c.sleuth.instrument.web.TraceFilter : Received a request to uri [/checked-out] that should not be sampled [false]
2017-10-30 12:52:05.168 DEBUG [book,05274e0bdf3038b9,05274e0bdf3038b9,true] 14088 --- [http-nio-8888-exec-2] o.s.c.sleuth.instrument.web.TraceFilter : No parent span present - creating a new span
2017-10-30 12:52:05.171 DEBUG [book,05274e0bdf3038b9,05274e0bdf3038b9,true] 14088 --- [http-nio-8888-exec-2] o.s.c.s.i.web.TraceHandlerInterceptor : Handling span [Trace: 05274e0bdf3038b9, Span: 05274e0bdf3038b9, Parent: null, exportable:true]
2017-10-30 12:52:05.171 DEBUG [book,05274e0bdf3038b9,05274e0bdf3038b9,true] 14088 --- [http-nio-8888-exec-2] o.s.c.s.i.web.TraceHandlerInterceptor : Adding a method tag with value [checkedOut] to a span [Trace: 05274e0bdf3038b9, Span: 05274e0bdf3038b9, Parent: null, exportable:true]
2017-10-30 12:52:05.172 DEBUG [book,05274e0bdf3038b9,05274e0bdf3038b9,true] 14088 --- [http-nio-8888-exec-2] o.s.c.s.i.web.TraceHandlerInterceptor : Adding a class tag with value [BookApplication] to a span [Trace: 05274e0bdf3038b9, Span: 05274e0bdf3038b9, Parent: null, exportable:true]
2017-10-30 12:52:05.174 DEBUG [book,05274e0bdf3038b9,05274e0bdf3038b9,true] 14088 --- [http-nio-8888-exec-2] o.s.c.sleuth.instrument.web.TraceFilter : Closing the span [Trace: 05274e0bdf3038b9, Span: 05274e0bdf3038b9, Parent: null, exportable:true] since the response was successful
2017-10-30 12:52:05.589 DEBUG [book,,,] 14088 --- [http-nio-8888-exec-2] o.s.c.sleuth.instrument.web.TraceFilter : Received a request to uri [/favicon.ico] that should not be sampled [true]
2017-10-30 12:52:05.589 DEBUG [book,b891d03ce6bccdf4,b891d03ce6bccdf4,false] 14088 --- [http-nio-8888-exec-2] o.s.c.sleuth.instrument.web.TraceFilter : No parent span present - creating a new span
2017-10-30 12:52:05.594 DEBUG [book,b891d03ce6bccdf4,b891d03ce6bccdf4,false] 14088 --- [http-nio-8888-exec-2] o.s.c.sleuth.instrument.web.TraceFilter : Closing the span [Trace: b891d03ce6bccdf4, Span: b891d03ce6bccdf4, Parent: null, exportable:false] since the response was successful

但我无法从 zipkin 控制台找到记录在 book.log 文件中的 traceId

您能解释一下为什么很多 span 没有报告给 zipkin 服务器吗?

提前致谢。

最佳答案

您的代码很可能已损坏。您可以查看 https://github.com/spring-cloud/spring-cloud-sleuth/blob/master/spring-cloud-sleuth-zipkin/src/main/java/org/springframework/cloud/sleuth/zipkin/ZipkinAutoConfiguration.java我们为 Edgware 添加了负载平衡 zipkin 服务器解析的类。

关于spring-cloud-netflix - ZipkinSpanReporter 无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47008485/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com