Package brave.mysql

Class 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 Detail

      • TracingStatementInterceptor

        public TracingStatementInterceptor()
    • Method Detail

      • 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