Package brave.mysql8
Class TracingQueryInterceptor
- java.lang.Object
-
- brave.mysql8.TracingQueryInterceptor
-
- All Implemented Interfaces:
com.mysql.cj.interceptors.QueryInterceptor
public class TracingQueryInterceptor extends Object implements com.mysql.cj.interceptors.QueryInterceptor
A MySQL query interceptor that will report to Zipkin how long each query takes.To use it, append
?queryInterceptors=brave.mysql8.TracingQueryInterceptorto the end of the connection url. It is also highly recommended to add&exceptionInterceptors=brave.mysql8.TracingExceptionInterceptorso errors are also included in spans.
-
-
Constructor Summary
Constructors Constructor Description TracingQueryInterceptor()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddestroy()booleanexecuteTopLevelOnly()com.mysql.cj.interceptors.QueryInterceptorinit(com.mysql.cj.MysqlConnection mysqlConnection, Properties properties, com.mysql.cj.log.Log log)<T extends com.mysql.cj.protocol.Resultset>
TpostProcess(Supplier<String> sql, com.mysql.cj.Query interceptedQuery, T originalResultSet, com.mysql.cj.protocol.ServerSession serverSession)<T extends com.mysql.cj.protocol.Resultset>
TpreProcess(Supplier<String> sqlSupplier, com.mysql.cj.Query interceptedQuery)UsesThreadLocalSpanas there's no attribute namespace shared between callbacks, but all callbacks happen on the same thread.
-
-
-
Method Detail
-
preProcess
public <T extends com.mysql.cj.protocol.Resultset> T preProcess(Supplier<String> sqlSupplier, com.mysql.cj.Query interceptedQuery)
UsesThreadLocalSpanas there's no attribute namespace shared between callbacks, but all callbacks happen on the same thread.Uses
ThreadLocalSpan.CURRENT_TRACERand this interceptor initializes before tracing.- Specified by:
preProcessin interfacecom.mysql.cj.interceptors.QueryInterceptor
-
postProcess
public <T extends com.mysql.cj.protocol.Resultset> T postProcess(Supplier<String> sql, com.mysql.cj.Query interceptedQuery, T originalResultSet, com.mysql.cj.protocol.ServerSession serverSession)
- Specified by:
postProcessin interfacecom.mysql.cj.interceptors.QueryInterceptor
-
executeTopLevelOnly
public boolean executeTopLevelOnly()
- Specified by:
executeTopLevelOnlyin interfacecom.mysql.cj.interceptors.QueryInterceptor
-
init
public com.mysql.cj.interceptors.QueryInterceptor init(com.mysql.cj.MysqlConnection mysqlConnection, Properties properties, com.mysql.cj.log.Log log)- Specified by:
initin interfacecom.mysql.cj.interceptors.QueryInterceptor
-
destroy
public void destroy()
- Specified by:
destroyin interfacecom.mysql.cj.interceptors.QueryInterceptor
-
-