简体   繁体   English

如何使用 Micrometer 配置 Spring Boot 3 和 Spring Stream(使用 RabbitMQ),在 Zipkin 中不分离跟踪 HTTP 和 MQ?

[英]How can I configure Spring Boot 3 with Micrometer and Spring Stream (with RabbitMQ) that does not separate trace HTTP and MQ in Zipkin?

I configured a basic Spring Boot with Micrometer and Spring Stream (with RabbitMQ).我配置了一个基本的 Spring Boot with Micrometer 和 Spring Stream (with RabbitMQ)。 I would like to configure that traceId can be passed into another service through Spring Stream.我想配置 traceId 可以通过 Spring Stream 传递到另一个服务中。

I understand it loses trace info when I use tryNextEmit.我知道当我使用 tryNextEmit 时它会丢失跟踪信息。 So it will generate a new.所以它会生成一个新的。 I also understand, RabbitMQ messages get a "traceparent" header with "00-xxxxxx-xxx-01" new value.我也明白,RabbitMQ 消息得到一个“traceparent”header 和“00-xxxxxx-xxx-01”新值。

So my question: How can I connect both traces that Spring Stream uses older trace information and one record appear in Zipkin?所以我的问题是:如何连接 Spring Stream 使用较旧跟踪信息和一条记录出现在 Zipkin 中的两条跟踪线?

Example code: https://github.com/Numichi/stackoverflow-question-micrometer-with-stream示例代码: https://github.com/Numichi/stackoverflow-question-micrometer-with-stream

Use StreamBridge to send the message to Cloud Stream bindings instead of using Sink.使用StreamBridge将消息发送到 Cloud Stream 绑定,而不是使用 Sink。 As you have mentioned, Sink does not allow Observation Context to propagate.正如您所提到的,Sink 不允许 Observation Context 传播。 I am not aware of any direct way of propagating the context when using sinks which will allow parent Observation to be passed down.我不知道在使用允许传递父 Observation 的接收器时传播上下文的任何直接方法。

If you send message to Stream binding using streambridge.send then message to rabbitMQ comes under parent observation as expected and shown below如果您使用streambridge.send将消息发送到 Stream 绑定,则发送到 rabbitMQ 的消息会按预期受到父观察,如下所示在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我可以使用 DLQ 为带有 RabbitMQ 的 Spring Cloud Stream 配置最大尝试吗 - Can I configure max tries for Spring Cloud Stream with RabbitMQ using DLQ 如何在Spring Boot Micrometer中传递New Relic Insights的应用程序名称 - How to pass application name for New Relic Insights in Spring boot micrometer 如何使用千分尺.io 和 kotlin(非 Spring 项目) - How can I use micrometer.io with kotlin(non Spring project) 如何使用Klaxon库配置Spring Boot - How to configure spring boot for using klaxon library 如何配置 spring-boot-starter-security - how to configure spring-boot-starter-security 如何使用 spring-cloud-stream 监听两个 RabbitMQ 队列 - How to listen to two RabbitMQ queues with spring-cloud-stream Spring Boot - RabbitMQ - 将消息内容类型从八位字节流更改为 json - Spring Boot - RabbitMQ - Changing message content type from octet-stream to json 如何在春季启动和Kotlin中初始化HTTP API - How to initlaize HTTP API to in spring boot and kotlin 如何配置我的 Spring Boot (Kotlin) 应用程序以将 / 重定向到 /swagger-ui.html? - How do I configure my Spring Boot (Kotlin) app to redirect / to /swagger-ui.html? 如何在 Spring 引导中检索 controller 内的 Kafka 消息? - How can I retrieve Kafka messages inside a controller in Spring Boot?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM