Spring JMS 消费者没有正确设置父跨度 ID
Spring JMS consumer does not have parent span Id rightly set
我的示例应用程序使用
- spring-boot-starter-activemq (2.3.1)
- spring-boot-starter-web (2.3.1)
- pring-cloud-starter-sleuth (2.2.3)
在已发布的消息中,我看到正确设置了 X-Parent-Span-Id、X-Trace-Id 和 b3 属性。但是,JMS 监听器(AMQ 消费者)中的日志具有不同的 parentId (X-B3-ParentSpanId)。
为什么 AMQ 消费者端的日志与消息中存在的 parentId 不同?
注意 - traceId 显示正常。
流量
服务器 1 --> 服务器 2(AMQ 生产者)---> AMQ 消费者
Server1 日志
{"@timestamp":"2020-07-26T18:42:19.258+01:00","@version":"1","message":"Received greet request","logger_name":"com.spike.server.HelloController","thread_name":"http-nio-8080-exec-9","level":"INFO","level_value":20000,"traceId":"e4ac9c00ba990cf2","spanId":"e4ac9c00ba990cf2","spanExportable":"true","X-Span-Export":"true","X-B3-SpanId":"e4ac9c00ba990cf2","X-B3-TraceId":"e4ac9c00ba990cf2"}
服务器 2(AMQ 生产者)日志
{"@timestamp":"2020-07-26T18:42:19.262+01:00","@version":"1","message":"Received audit request","logger_name":"com.spike.upstream.AuditController","thread_name":"http-nio-8081-exec-9","level":"INFO","level_value":20000,"traceId":"e4ac9c00ba990cf2","spanId":"aed4a3863c141dde","spanExportable":"true","X-Span-Export":"true","X-B3-SpanId":"aed4a3863c141dde","X-B3-ParentSpanId":"e4ac9c00ba990cf2","X-B3-TraceId":"e4ac9c00ba990cf2","parentId":"e4ac9c00ba990cf2"}
AMQ 消费者日志
{"@timestamp":"2020-07-26T18:42:19.270+01:00","@version":"1","message":"Received message: hello world","logger_name":"com.spike.consumer.Consumer","thread_name":"DefaultMessageListenerContainer-1","level":"INFO","level_value":20000,"traceId":"e4ac9c00ba990cf2","spanId":"9f7928f65ee2479d","spanExportable":"true","X-Span-Export":"true","X-B3-SpanId":"9f7928f65ee2479d","X-B3-ParentSpanId":"70f25884c40b2dc7","X-B3-TraceId":"e4ac9c00ba990cf2","parentId":"70f25884c40b2dc7"}
我想我明白你的问题了。因此,父 ID 的不匹配与我们在消费者和生产者之间引入“jms”服务这一事实有关,如果代理是相关的,您会看到代理需要多长时间。在 Imgur https://imgur.com/a/rpcFz4l
中查看以下图片
我的示例应用程序使用
- spring-boot-starter-activemq (2.3.1)
- spring-boot-starter-web (2.3.1)
- pring-cloud-starter-sleuth (2.2.3)
在已发布的消息中,我看到正确设置了 X-Parent-Span-Id、X-Trace-Id 和 b3 属性。但是,JMS 监听器(AMQ 消费者)中的日志具有不同的 parentId (X-B3-ParentSpanId)。
为什么 AMQ 消费者端的日志与消息中存在的 parentId 不同?
注意 - traceId 显示正常。
流量
服务器 1 --> 服务器 2(AMQ 生产者)---> AMQ 消费者
Server1 日志
{"@timestamp":"2020-07-26T18:42:19.258+01:00","@version":"1","message":"Received greet request","logger_name":"com.spike.server.HelloController","thread_name":"http-nio-8080-exec-9","level":"INFO","level_value":20000,"traceId":"e4ac9c00ba990cf2","spanId":"e4ac9c00ba990cf2","spanExportable":"true","X-Span-Export":"true","X-B3-SpanId":"e4ac9c00ba990cf2","X-B3-TraceId":"e4ac9c00ba990cf2"}
服务器 2(AMQ 生产者)日志
{"@timestamp":"2020-07-26T18:42:19.262+01:00","@version":"1","message":"Received audit request","logger_name":"com.spike.upstream.AuditController","thread_name":"http-nio-8081-exec-9","level":"INFO","level_value":20000,"traceId":"e4ac9c00ba990cf2","spanId":"aed4a3863c141dde","spanExportable":"true","X-Span-Export":"true","X-B3-SpanId":"aed4a3863c141dde","X-B3-ParentSpanId":"e4ac9c00ba990cf2","X-B3-TraceId":"e4ac9c00ba990cf2","parentId":"e4ac9c00ba990cf2"}
AMQ 消费者日志
{"@timestamp":"2020-07-26T18:42:19.270+01:00","@version":"1","message":"Received message: hello world","logger_name":"com.spike.consumer.Consumer","thread_name":"DefaultMessageListenerContainer-1","level":"INFO","level_value":20000,"traceId":"e4ac9c00ba990cf2","spanId":"9f7928f65ee2479d","spanExportable":"true","X-Span-Export":"true","X-B3-SpanId":"9f7928f65ee2479d","X-B3-ParentSpanId":"70f25884c40b2dc7","X-B3-TraceId":"e4ac9c00ba990cf2","parentId":"70f25884c40b2dc7"}
我想我明白你的问题了。因此,父 ID 的不匹配与我们在消费者和生产者之间引入“jms”服务这一事实有关,如果代理是相关的,您会看到代理需要多长时间。在 Imgur https://imgur.com/a/rpcFz4l
中查看以下图片