spring-webflux - Sleuth 3.0.1 + Spring Cloud Gateway = traceids 与请求/响应不相关
问题描述
好吧,我有一个使用 Sleuth 3.0.1 的新设置,默认情况下spring.sleuth.reactor.instrumentation-type
设置为manual
因此,我用逻辑包裹了我需要跟踪的所有地方,WebFluxSleuthOperators.withSpanInScope(tracer, currentTraceContext, exchange, () -> {})
它通常将 span 放在范围内,但在收到响应之前和之后 traceid 总是不同的:
INFO [gateway,2b601780f2242aa9,2b601780f2242aa9] 9 --- [or-http-epoll-1] ...LogFilter : Request - Username: ..., method: GET, uri: ...
INFO [gateway,,] 9 --- [or-http-epoll-1] ...ValidationFilter : ... Validation passed
INFO [gateway,6a396715ff0979a6,6a396715ff0979a6] 9 --- [or-http-epoll-4] ...LogFilter : Request - Username: ..., method: GET, uri: ...
INFO [gateway,,] 9 --- [or-http-epoll-4] ...ValidationFilter : ... Validation passed
INFO [gateway,020c11ab0c37f8ae,020c11ab0c37f8ae] 9 --- [or-http-epoll-2] ...LogFilter : Request - Username: ..., method: GET, uri: ...
INFO [gateway,,] 9 --- [or-http-epoll-2] ...ValidationFilter : Validation passed
INFO [gateway,189a49553566f771,f51aaaf68e5738d0] 9 --- [or-http-epoll-1] ...LogFilter : Response - Status: 200 OK
INFO [gateway,92f25dcff9833079,87db5f7b1cbefedb] 9 --- [or-http-epoll-2] ...LogFilter : Response - Status: 200 OK
INFO [gateway,d8b133f2200e7808,1743df4b5ad37d07] 9 --- [or-http-epoll-1] ...LogFilter : Response - Status: 400 BAD_REQUEST
深入挖掘,似乎返回的跨度exchange.getAttribute(Span.class.getName());
在路由后阶段具有不同的跟踪 ID。
当然更改检测类型以decorate_on_last
解决问题,但希望避免不必要的性能下降。
解决方案
推荐阅读
- ios - [Material Components iOS][TextFields] 在主视图和文本字段之间添加边距
- c# - 使用 DbSet 查找和延迟加载偶尔为空的实体框架外键
- java - 是否有任何参数表明我希望在不实现可序列化接口的情况下对所有类(或我的整个应用程序)进行序列化?
- sql - 基于现有表/查询中的条目创建查询的 VBA 脚本
- locale - 将语言环境从 Spring Web App 传递到 KeyCloak 并返回
- javascript - 加载外部js文件时如何动态替换代码?
- angular - 效果“AuthEffects.authLogin$”发送了一个无效动作:未定义
- css - 对匹配属性的反向引用
- python - Pymongo:迭代字典列表的字典
- php - 远程mysql数据库连接问题