问题描述
我想在微服务中实现分布式跟踪(使用 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 (将#修改为@)