如何解决微服务分布式跟踪不起作用
我想在微服务中实现分布式跟踪(使用 sleuth-otel),它应该将跟踪详细信息导出到 Google 云跟踪 Api(不是 zipkin)。 应用结构是这样的, 服务 1 -> 发布订阅 -> 服务 2 -> 发布订阅 -> 服务 3 我尝试了以下
A) 在服务 1,
- 我在 pom.xml 中添加了
spring-cloud-starter-sleuth
和spring-cloud-sleuth-otel
依赖项 - 我在 application.properties 中添加了以下内容
spring.sleuth.integration.enabled=true
spring.sleuth.sampler.probability=1
spring.application.name=service1
spring.sleuth.otel.log.slf4j.enabled=true
spring.sleuth.otel.log.exporter.enabled=true
- 在运行第一个服务时,我看到了这样的日志
INFO [,2f571809528f9daa,2983cfebab529366]
我对此的看法是,
=> 为什么我没有看到我在 application.properties 中提到的应用程序名称。还有什么我错过的吗?
=> 我也想用我自己的值来改变这个默认的 traceId。是否有可能?如果是,我该怎么做?(示例代码请)
B) 在服务 2
- 我在 pom.xml 中添加了相同的
spring-cloud-starter-sleuth
和spring-cloud-sleuth-otel
依赖项 - 还在 application.properties 中添加了这些
spring.sleuth.integration.enabled=true
spring.sleuth.sampler.probability=1
spring.application.name=service2
spring.sleuth.otel.log.slf4j.enabled=true
spring.sleuth.otel.log.exporter.enabled=true
- 在运行 service2 时,我得到了这样的日志
INFO [service2,]
怀疑
=> 为什么我在这里没有在 service1 中获得相同的 traceId 登录?(它也没有记录 spanId)
Note:i debugged the data received from pubsub in service2,in that i saw the same traceId is there in pubsub data header. So,i confirmed that,the traceId generated from service1 is passing along with the response header but it doesn't log in service2.
=> 如何在 service2 中获取相同的 traceId?
=> 要将跟踪导出到谷歌云跟踪 API,此依赖项就足够了,还是我需要添加任何配置或其他内容?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。