The brave-mysql module includes classes which will record the time taken to execute SQL queries as well as the query that was executed for the MySQL database.
- Inject
ClientTracer
intoMySQLStatementInterceptorManagementBean
. E.g.
Brave brave = new Brave.Builder("myService").build();
new MySQLStatementInterceptorManagementBean(brave.clientTracer());
or Spring IoC
<bean id="braveBuilder" class="com.github.kristofa.brave.Brave.Builder">
<contructor-arg value="myService" />
</bean>
<bean id="brave" factory-bean="braveBuilder" factory-method="build" />
<bean class="com.github.kristofa.brave.mysql.MySQLStatementInterceptorManagementBean"
destroy-method="close">
<constructor-arg value="#{brave.clientTracer()}" />
</bean>
- Append
?statementInterceptors=com.github.kristofa.brave.mysql.MySQLStatementInterceptor
to the end of the JDBC connection string. By default the service name of this span will use the formatmysql-${database}
, but you can append another propertyzipkinServiceName
to customise it.
?statementInterceptors=com.github.kristofa.brave.mysql.MySQLStatementInterceptor&zipkinServiceName=myDatabaseService
Note: Here the myDatabaseService differs from the above myService, the former one is the Java application service name, but the latter one is the service name of your MySQL database.