gpt4 book ai didi

java - Spring Boot 微服务中的 Spring Cloud Sleuth 日志跟踪

转载 作者:行者123 更新时间:2023-11-30 02:08:16 25 4
gpt4 key购买 nike

我有 2 个使用 Spring Cloud Stream 和 Kafka Binder 的 Spring Boot 微服务。我正在使用 Spring cloud sleuth 依赖项进行日志跟踪。在微服务 A 中,在向 kafka 中的主题发布事件时,我将 trackId 设置为

ExtraFieldPropagation.set("trackId","valueHeader");

我没有在微服务 B 中获取该值作为行李 header 。我获取了 TraceId、SpanID,但没有获取我在上面设置的行李元素。

最佳答案

您阅读过本节下的文档吗? https://cloud.spring.io/spring-cloud-static/Finchley.RC2/single/spring-cloud.html#_prefixed_fields

A difference from previous versions of Sleuth is that, with Brave, you must pass the list of baggage keys. There are two properties to achieve this. With the spring.sleuth.baggage-keys, you set keys that get prefixed with baggage- for HTTP calls and baggage_ for messaging. You can also use the spring.sleuth.propagation-keys property to pass a list of prefixed keys that are whitelisted without any prefix.

您是否明确提供了行李 key ?例如。 https://github.com/spring-cloud-samples/sleuth-documentation-apps/blob/master/service1/src/main/resources/application.yaml#L9-L11

spring:
sleuth:
# you have to explicitly provide baggage keys
baggage-keys:
- trackId
- valueHeader

关于java - Spring Boot 微服务中的 Spring Cloud Sleuth 日志跟踪,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50868576/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com