gpt4 book ai didi

mysql - 使用 AWS X-Ray 在 Spring 中检测 Mysql Jpa Repository 不工作

转载 作者:行者123 更新时间:2023-11-29 02:42:19 24 4
gpt4 key购买 nike

我正在尝试在我的 spring 应用程序中使用 AWS X-Ray 检测 Mysql 调用。 http 和 s3 检测工作正常。

我已经设置了属性:spring.datasource.jdbc-interceptors=com.amazonaws.xray.sql.mysql.TracingInterceptor

我在 build.gradle 中包含了以下依赖

compile 'com.amazonaws:aws-xray-recorder-sdk-spring'
compile("com.amazonaws:aws-xray-recorder-sdk-core")
compile("com.amazonaws:aws-xray-recorder-sdk-aws-sdk")
compile("com.amazonaws:aws-xray-recorder-sdk-aws-sdk-instrumentor")
compile("com.amazonaws:aws-xray-recorder-sdk-apache-http")
compile("com.amazonaws:aws-xray-recorder-sdk-sql-mysql")
dependencyManagement {
imports {
mavenBom('com.amazonaws:aws-xray-recorder-sdk-bom:1.3.1')
}
}

我正在使用 JpaRepositories。我希望我的所有 sql 查询在完成上述设置后自动检测。我在这个位置关注亚马逊文档:https://docs.aws.amazon.com/xray/latest/devguide/xray-sdk-java-sqlclients.html

我错过了什么?

更新:我可以看到 mysql 跟踪 spring 的健康端点。但是仍然看不到 jpa 调用。

最佳答案

您是否正在使用 application.properties 中定义的 spring.datasource 属性构建 DataSource 对象?

请参阅 RdsWebConfig 类中的 dataSource() 方法 ( GitHub ),它使用 @ConfigurationProperties(prefix = "spring.datasource") 注释以获取相关的 jdbc-interceptors 属性。

希望这对您有所帮助。

詹姆斯

关于mysql - 使用 AWS X-Ray 在 Spring 中检测 Mysql Jpa Repository 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48978723/

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