Skip to content

Latest commit

 

History

History
 
 

brave-mysql

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

brave-mysql

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.

Using

  1. Inject ClientTracer into MySQLStatementInterceptorManagementBean. 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>
  1. 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 format mysql-${database}, but you can append another property zipkinServiceName 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.