我有一个使用 Springboot 应用程序运行 Fargate 实例的 ECS 集群,并且希望以最少的代码更改来启用跟踪。我开始研究两种方法:
使用 AWS-Xray:步骤 -> 添加依赖项,添加 WSXRayServletFilter,在单独的容器中运行 X-Ray 守护程序。
使用 Spring Cloud Sleuth :步骤 -> 添加依赖项和属性,与 X-Ray 集成
因此,第二种方法可以节省您修改代码的步骤,问题是我找不到任何好的文档来将 Spring Cloud Sleuth 与 X-Ray 集成,任何人都可以指出我正确的方向吗?
我尝试阅读大量文档,包括:https://cloud.spring.io/spring-cloud-sleuth/spring-cloud-sleuth.html https://cloud.spring.io/spring-cloud-sleuth/spring-cloud-sleuth.html
我在寻找选项二的解决方案时遇到了这个问题。 AFAIK,你仍然需要使用X 射线守护进程 https://docs.aws.amazon.com/xray/latest/devguide/xray-daemon-configuration.html。我必须查看多个 GitHub 存储库和问题才能解决问题,因此我在这里提供解决方案。
我的解决方案使用 Gradle,但这也可以轻松转换为 Maven。
添加Spring Cloud的BOM
dependencyManagement {
imports {
mavenBom("org.springframework.cloud:spring-cloud-dependencies:2021.0.3")
}
}
将以下依赖项添加到项目中。
implementation 'org.springframework.cloud:spring-cloud-starter-sleuth'
implementation 'org.springframework.cloud:spring-cloud-sleuth-zipkin'
implementation 'io.zipkin.aws:zipkin-reporter-xray-udp:0.23.4'
然后添加配置以定义用于向 X-Ray 守护程序报告的 Bean。
@Configuration
public class TracingConfiguration {
@Bean(ZipkinAutoConfiguration.REPORTER_BEAN_NAME)
Reporter<Span> reporter() {
return XRayUDPReporter.create();
}
}
根据文档将 Sleuth 的传播类型定义为 aws。
spring.sleuth.propagation.type=aws
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)