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

    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)
    Uses ThreadLocalSpan as there's no attribute namespace shared between callbacks, but all callbacks happen on the same thread.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • preProcess

      public com.mysql.jdbc.ResultSetInternalMethods preProcess​(String sql, com.mysql.jdbc.Statement interceptedStatement, com.mysql.jdbc.Connection connection)
      Uses ThreadLocalSpan 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 interface com.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 interface com.mysql.jdbc.StatementInterceptorV2
    • executeTopLevelOnly

      public boolean executeTopLevelOnly()
      Specified by:
      executeTopLevelOnly in interface com.mysql.jdbc.StatementInterceptorV2
    • init

      public void init​(com.mysql.jdbc.Connection conn, Properties props)
      Specified by:
      init in interface com.mysql.jdbc.Extension
      Specified by:
      init in interface com.mysql.jdbc.StatementInterceptorV2
    • destroy

      public void destroy()
      Specified by:
      destroy in interface com.mysql.jdbc.Extension
      Specified by:
      destroy in interface com.mysql.jdbc.StatementInterceptorV2