Package brave.mysql
Class TracingStatementInterceptor
- java.lang.Object
-
- brave.mysql.TracingStatementInterceptor
-
- All Implemented Interfaces:
com.mysql.jdbc.Extension
,com.mysql.jdbc.StatementInterceptorV2
public class TracingStatementInterceptor extends Object implements com.mysql.jdbc.StatementInterceptorV2
A MySQL statement interceptor that will report to Zipkin how long each statement takes.To use it, append
?statementInterceptors=brave.mysql.TracingStatementInterceptor
to the end of the connection url.
-
-
Constructor Summary
Constructors Constructor Description TracingStatementInterceptor()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
destroy()
boolean
executeTopLevelOnly()
void
init(com.mysql.jdbc.Connection conn, Properties props)
com.mysql.jdbc.ResultSetInternalMethods
postProcess(String sql, com.mysql.jdbc.Statement interceptedStatement, com.mysql.jdbc.ResultSetInternalMethods originalResultSet, com.mysql.jdbc.Connection connection, int warningCount, boolean noIndexUsed, boolean noGoodIndexUsed, SQLException statementException)
com.mysql.jdbc.ResultSetInternalMethods
preProcess(String sql, com.mysql.jdbc.Statement interceptedStatement, com.mysql.jdbc.Connection connection)
UsesThreadLocalSpan
as there's no attribute namespace shared between callbacks, but all callbacks happen on the same thread.
-
-
-
Method Detail
-
preProcess
public com.mysql.jdbc.ResultSetInternalMethods preProcess(String sql, com.mysql.jdbc.Statement interceptedStatement, com.mysql.jdbc.Connection connection)
UsesThreadLocalSpan
as there's no attribute namespace shared between callbacks, but all callbacks happen on the same thread.Uses
ThreadLocalSpan.CURRENT_TRACER
and this interceptor initializes before tracing.- Specified by:
preProcess
in interfacecom.mysql.jdbc.StatementInterceptorV2
-
postProcess
public com.mysql.jdbc.ResultSetInternalMethods postProcess(String sql, com.mysql.jdbc.Statement interceptedStatement, com.mysql.jdbc.ResultSetInternalMethods originalResultSet, com.mysql.jdbc.Connection connection, int warningCount, boolean noIndexUsed, boolean noGoodIndexUsed, SQLException statementException)
- Specified by:
postProcess
in interfacecom.mysql.jdbc.StatementInterceptorV2
-
executeTopLevelOnly
public boolean executeTopLevelOnly()
- Specified by:
executeTopLevelOnly
in interfacecom.mysql.jdbc.StatementInterceptorV2
-
init
public void init(com.mysql.jdbc.Connection conn, Properties props)
- Specified by:
init
in interfacecom.mysql.jdbc.Extension
- Specified by:
init
in interfacecom.mysql.jdbc.StatementInterceptorV2
-
destroy
public void destroy()
- Specified by:
destroy
in interfacecom.mysql.jdbc.Extension
- Specified by:
destroy
in interfacecom.mysql.jdbc.StatementInterceptorV2
-
-