3

I am trying to instrument Mysql calls using AWS X-Ray in my spring application. http and s3 instrumentation is working fine.

I have set the property: spring.datasource.jdbc-interceptors=com.amazonaws.xray.sql.mysql.TracingInterceptor

I have included following dependancies in 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')
    }
}

I am using JpaRepositories. I am expecting all my sql queries to get instrumented automatically after above setup is done. I am following amazon doc at this location: https://docs.aws.amazon.com/xray/latest/devguide/xray-sdk-java-sqlclients.html

What am I missing?

Update: I can see mysql traces for spring's health endpoint. But jpa calls are still unseen.

kishor borate
  • 158
  • 1
  • 11

1 Answers1

1

Are you constructing the DataSource object using the defined spring.datasource properties in your application.properties?

See this dataSource() method (GitHub) in the RdsWebConfig class which uses the @ConfigurationProperties(prefix = "spring.datasource") annotation in order to pick up the relevant jdbc-interceptors property.

Hope this helps.

James

James Bowman
  • 151
  • 2
  • 1
    As far as I understand, if you rely on Spring autoconfiguration to initialize your DataSource, this shouldn't be necessary. I'm assuming OP sets up the database credentials via Spring properties as well which arguably are picked up. – jlaitio Apr 06 '18 at 10:04