You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@zipkin.apache.org by GitBox <gi...@apache.org> on 2019/05/12 22:31:42 UTC

[GitHub] [incubator-zipkin-brave] patrickbray commented on issue #609: Don't make spans for comments or SET statements in SQL

patrickbray commented on issue #609: Don't make spans for comments or SET statements in SQL
URL: https://github.com/apache/incubator-zipkin-brave/issues/609#issuecomment-491634862
 
 
   Firstly thanks for all the awesome work on Zipkin and this instrumentation @adriancole . 
   
   I ran into this issue today and have forked the mysql TracingStatementInterceptor locally and introduced a regex for excluding certain SQL statements. i.e. 
   
   ```
   private Pattern exclude = Pattern.compile("(set.+)|(commit)|(select @@session.tx_read_only)", Pattern.CASE_INSENSITIVE);
   
       @Override
       public ResultSetInternalMethods preProcess(String sql, Statement interceptedStatement,
                                                  Connection connection) {
   
           // When running a prepared statement, sql will be null and we must fetch the sql from the statement itself
           if (interceptedStatement instanceof PreparedStatement) {
               sql = ((PreparedStatement) interceptedStatement).getPreparedSql();
           }
   
           if (exclude.matcher(sql).matches()) {
               return null;
           }
   
   ...
   
   ```
   
   This works for us at the moment as we are generally using this locally to help identify perf issues etc but not sure this is a solution you would want to add for this issue? If so would be more than willing to submit a PR. 
   
   I guess some concerns would be the performance impact of adding a regex as part of this instrumentation and possibly making this regex configurable? Though not sure what the best approach for that would be?
   
   I also ran into an interesting deadlock issue when 1st adding this instrumentation to an existing Spring Boot / Sleuth application with a c3po connection pool as outlined [here](https://stackoverflow.com/questions/56070700/deadlock-starting-c3po-connection-pool-with-zipkin-tracingstatementinterceptor) in case anyone else has a similar issue.   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@zipkin.apache.org
For additional commands, e-mail: dev-help@zipkin.apache.org