简体   繁体   English

在迁移到 Spring Boot 3.0.1/Spring Cloud 2022.0.0 后,跨 HTTP REST 和 Kinesis 消息传递服务边界传播跟踪 ID

[英]Propagating trace IDs across HTTP REST and Kinesis messaging service boundaries after migrating to Spring Boot 3.0.1/Spring Cloud 2022.0.0

I am in the middle of migrating code from Spring Boot 2.7.7/Spring Cloud 2021.0.5 to Spring Boot 3.0.1/Spring Cloud 2022.0.0.我正在将代码从 Spring Boot 2.7.7/Spring Cloud 2021.0.5 迁移到 Spring Boot 3.0.1/Spring Cloud 2022.0.0。 As part of this migration, I now am using io.micrometer:micrometer-tracing-bridge-otel .作为此迁移的一部分,我现在使用io.micrometer:micrometer-tracing-bridge-otel While I have my code functionally working, I have noticed that the traceId is no longer propagated across HTTP REST or Kinesis messaging service boundaries (ie, my HTTP REST client/server and Kinesis messaging producer/consumer microservices log separate traceId s).虽然我的代码可以正常工作,但我注意到traceId不再传播到 HTTP REST 或 Kinesis 消息传递服务边界(即,我的 HTTP REST 客户端/服务器和 Kinesis 消息传递生产者/消费者微服务记录单独的traceId s)。 Is there an additional dependency or dependencies I need to add to my projects to ensure that the traceId gets propagated across service boundaries?是否需要向我的项目添加额外的依赖项或依赖项以确保traceId跨服务边界传播?

As FYI, with Spring Boot 2.7.7/Spring Cloud 2021.0.5, I was able to propagate the traceId across Kinesis producers and consumers with the following configuration (no separate configuration was needed to propagate the traceId across HTTP REST boundaries) - adding the b3 header was the key to getting traceId propagation working:仅供参考,使用 Spring Boot 2.7.7/Spring Cloud 2021.0.5,我能够使用以下配置在 Kinesis 生产者和消费者之间传播traceId (不需要单独的配置来跨 HTTP REST 边界传播traceId )——添加b3 header 是让traceId传播工作的关键:

spring:
  cloud:
    stream:
      bindings:
        myEvent-out-0:
          content-type: application/*+avro
          destination: my-event
      kinesis:
        binder:
          auto-create-stream: true
          headers:
            - b3
          kpl-kcl-enabled: true

I noticed here it states that "by default we don't support joined spans (this means that when you have eg an HTTP span, you will no longer see the same span being there on the client and sender side, you will see two separate spans now)."在这里注意到它指出“默认情况下我们不支持连接跨度(这意味着当你有一个 HTTP 跨度时,你将不再在客户端和发件人端看到相同的跨度,你会看到两个单独的跨度现在跨越)。 So, when it states that by default it's not supported, does this mean that this is an optional configuration?那么,当它声明默认情况下不支持它时,这是否意味着这是一个可选配置? This statement confuses me, and I'm wondering why the decision was to not join spans as the default auto-configuration when this is clearly what is needed for log correlation across a distributed architecture.这句话让我感到困惑,我想知道为什么决定不加入 span 作为默认自动配置,而这显然是跨分布式架构的日志关联所需要的。

So, in summary, I am seeking guidance regarding how to configure Micrometer Tracing so that traceId s are always propagated across service boundaries, whether they are HTTP REST or message boundaries.因此,总而言之,我正在寻求有关如何配置 Micrometer Tracing 的指导,以便traceId始终跨服务边界传播,无论它们是 HTTP REST 还是消息边界。 What is the bare minimum configuration required to get this working?让这个工作所需的最低配置是什么?

Not sure if that will help you, but what I have learned that Spring Boot 3 uses a W3C propagation by default: https://github.com/micrometer-metrics/tracing/wiki/Spring-Cloud-Sleuth-3.1-Migration-Guide .不确定这是否对您有帮助,但我了解到 Spring Boot 3 默认使用 W3C 传播: https://github.com/micrometer-metrics/tracing/wiki/Spring-Cloud-Sleuth-3.1-Migration-指南

Therefore, the header you need to embed into Kinesis Producer record is exactly baggage .因此,您需要嵌入到 Kinesis Producer 记录中的 header 正是baggage

See more info in Spring Boot docs: https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#actuator.micrometer-tracing在 Spring 引导文档中查看更多信息: https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#actuator.micrometer-tracing

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM