Spring Sleuth跟踪ID已在Spring Cloud Gateway中消失



我有一个非常简单的spring云网关应用程序(没有自定义,直接从start.spring.io下载,只需选择gateway和sleuth(。要启用访问日志,我必须设置系统属性reactor.netty.http.server.accessLogEnabled:

@SpringBootApplication
class Application
fun main(args: Array<String>) {
System.setProperty(ReactorNetty.ACCESS_LOG_ENABLED, "true")
runApplication<Application>(*args)
}

一切都很好:

...
2021-12-27 17:19:05.245  INFO [gateway,,] 62156 --- [           main] o.s.b.web.embedded.netty.NettyWebServer  : Netty started on port 8080
2021-12-27 17:19:05.284  INFO [gateway,,] 62156 --- [           main] com.example.demo.ApplicationKt           : Started ApplicationKt in 1.855 seconds (JVM running for 2.262)
2021-12-27 17:19:09.914  INFO [gateway,e075b59a8a4bca5d,e075b59a8a4bca5d] 62156 --- [ctor-http-nio-2] reactor.netty.http.server.AccessLog      : 127.0.0.1 - - [27/Dec/2021:17:19:09 +0100] "GET /get HTTP/1.1" 404 132 111

现在,当我向应用程序添加路由时:

@SpringBootApplication
class Application
fun main(args: Array<String>) {
System.setProperty(ReactorNetty.ACCESS_LOG_ENABLED, "true")
runApplication<Application>(*args) {
addInitializers(
beans {
bean {
ref<RouteLocatorBuilder>().routes {
route {
path("/*")
uri("https://httpbin.org")
}
}
}
}
)
}
}

追踪信息消失了:

2021-12-27 17:23:48.010  INFO [gateway,,] 62423 --- [           main] o.s.b.web.embedded.netty.NettyWebServer  : Netty started on port 8080
2021-12-27 17:23:48.042  INFO [gateway,,] 62423 --- [           main] com.example.demo.ApplicationKt           : Started ApplicationKt in 1.774 seconds (JVM running for 2.145)
2021-12-27 17:24:21.864  INFO [gateway,,] 62423 --- [ctor-http-nio-2] reactor.netty.http.server.AccessLog      : 127.0.0.1 - - [27/Dec/2021:17:24:20 +0100] "GET /get HTTP/1.1" 200 613 949

application.xml中定义的路由也会发生这种情况
我缺少什么?配置路由时需要做什么吗?

他们对spring-boot 2.4做了一些更改。查看此处的发布说明-https://github.com/spring-cloud/spring-cloud-sleuth/wiki/Spring-Cloud-Sleuth-3.0-Migration-Guide#spring-云网关手动反应堆跟踪仪器

相关内容

  • 没有找到相关文章

最新更新