com.p6spy.engine.common.StatementInformation Java Examples

The following examples show how to use com.p6spy.engine.common.StatementInformation. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TracingJdbcEventListener.java    From spring-boot-data-source-decorator with Apache License 2.0 5 votes vote down vote up
@Override
public void onAfterExecuteUpdate(StatementInformation statementInformation, long timeElapsedNanos, String sql, int rowCount, SQLException e) {
    if (e == null) {
        strategy.addQueryRowCount(statementInformation.getConnectionInformation(), statementInformation, rowCount);
    }
    super.onAfterExecuteUpdate(statementInformation, timeElapsedNanos, sql, rowCount, e);
}
 
Example #2
Source File: TracingJdbcEventListener.java    From brave with Apache License 2.0 5 votes vote down vote up
/**
 * Uses {@link ThreadLocalSpan} as there's no attribute namespace shared between callbacks, but
 * all callbacks happen on the same thread.
 *
 * <p>Uses {@link ThreadLocalSpan#CURRENT_TRACER} and this interceptor initializes before
 * tracing.
 */
@Override public void onBeforeAnyExecute(StatementInformation info) {
  String sql = includeParameterValues ? info.getSqlWithValues() : info.getSql();
  if (!isLoggable(sql)) return;

  // Gets the next span (and places it in scope) so code between here and postProcess can read it
  Span span = ThreadLocalSpan.CURRENT_TRACER.next();
  if (span == null || span.isNoop()) return;

  int spaceIndex = sql.indexOf(' '); // Allow span names of single-word statements like COMMIT
  span.kind(CLIENT).name(spaceIndex == -1 ? sql : sql.substring(0, spaceIndex));
  span.tag("sql.query", sql);
  parseServerIpAndPort(info.getConnectionInformation().getConnection(), span);
  span.start();
}
 
Example #3
Source File: TracingJdbcEventListener.java    From brave with Apache License 2.0 5 votes vote down vote up
@Override public void onAfterAnyExecute(StatementInformation info, long elapsed, SQLException e) {
  Span span = ThreadLocalSpan.CURRENT_TRACER.remove();
  if (span == null || span.isNoop()) return;

  if (e != null) {
    span.error(e);
    span.tag("error", Integer.toString(e.getErrorCode()));
  }
  span.finish();
}
 
Example #4
Source File: MetricJdbcEventListener.java    From summerframework with Apache License 2.0 4 votes vote down vote up
@Override
public void onAfterAnyAddBatch(StatementInformation statementInformation, long timeElapsedNanos, SQLException e) {
    record(statementInformation, timeElapsedNanos, Category.BATCH, e);
}
 
Example #5
Source File: MetricJdbcEventListener.java    From summerframework with Apache License 2.0 4 votes vote down vote up
@Override
public void onAfterAnyExecute(StatementInformation statementInformation, long timeElapsedNanos, SQLException e) {
    record(statementInformation, timeElapsedNanos, Category.STATEMENT, e);
}
 
Example #6
Source File: MetricJdbcEventListener.java    From summerframework with Apache License 2.0 4 votes vote down vote up
@Override
public void onAfterExecuteBatch(StatementInformation statementInformation, long timeElapsedNanos,
    int[] updateCounts, SQLException e) {
    record(statementInformation, timeElapsedNanos, Category.BATCH, e);
}
 
Example #7
Source File: MetricJdbcEventListener.java    From summerframework with Apache License 2.0 4 votes vote down vote up
@Override
public void onAfterGetResultSet(StatementInformation statementInformation, long timeElapsedNanos, SQLException e) {
    record(statementInformation, timeElapsedNanos, Category.RESULTSET, e);
}
 
Example #8
Source File: MyLoggingEventListener.java    From summerframework with Apache License 2.0 4 votes vote down vote up
@Override
public void onAfterAnyAddBatch(StatementInformation statementInformation, long timeElapsedNanos, SQLException e) {
    logElapsed(statementInformation, timeElapsedNanos, Category.BATCH, e);
}
 
Example #9
Source File: MyLoggingEventListener.java    From summerframework with Apache License 2.0 4 votes vote down vote up
@Override
public void onAfterAnyExecute(StatementInformation statementInformation, long timeElapsedNanos, SQLException e) {
    logElapsed(statementInformation, timeElapsedNanos, Category.STATEMENT, e);
}
 
Example #10
Source File: MyLoggingEventListener.java    From summerframework with Apache License 2.0 4 votes vote down vote up
@Override
public void onAfterExecuteBatch(StatementInformation statementInformation, long timeElapsedNanos,
    int[] updateCounts, SQLException e) {
    logElapsed(statementInformation, timeElapsedNanos, Category.BATCH, e);
}
 
Example #11
Source File: MyLoggingEventListener.java    From summerframework with Apache License 2.0 4 votes vote down vote up
@Override
public void onAfterGetResultSet(StatementInformation statementInformation, long timeElapsedNanos, SQLException e) {
    logElapsed(statementInformation, timeElapsedNanos, Category.RESULTSET, e);
}
 
Example #12
Source File: TracingJdbcEventListener.java    From spring-boot-data-source-decorator with Apache License 2.0 4 votes vote down vote up
@Override
public void onBeforeAnyExecute(StatementInformation statementInformation) {
    String dataSourceName = dataSourceNameResolver.resolveDataSourceName(statementInformation.getConnectionInformation().getDataSource());
    strategy.beforeQuery(statementInformation.getConnectionInformation(), statementInformation, dataSourceName);
}
 
Example #13
Source File: TracingJdbcEventListener.java    From spring-boot-data-source-decorator with Apache License 2.0 4 votes vote down vote up
@Override
public void onAfterAnyExecute(StatementInformation statementInformation, long timeElapsedNanos, SQLException e) {
    strategy.afterQuery(statementInformation.getConnectionInformation(), statementInformation, getSql(statementInformation), e);
}
 
Example #14
Source File: TracingJdbcEventListener.java    From spring-boot-data-source-decorator with Apache License 2.0 4 votes vote down vote up
@Override
public void onAfterStatementClose(StatementInformation statementInformation, SQLException e) {
    strategy.afterStatementClose(statementInformation.getConnectionInformation(), statementInformation);
}
 
Example #15
Source File: TracingJdbcEventListener.java    From spring-boot-data-source-decorator with Apache License 2.0 4 votes vote down vote up
private String getSql(StatementInformation statementInformation) {
    return includeParameterValues && StringUtils.hasText(statementInformation.getSqlWithValues())
            ? statementInformation.getSqlWithValues()
            : statementInformation.getSql();
}