use of com.navercorp.pinpoint.bootstrap.context.ParsingResult in project pinpoint by naver.
the class DefaultCachingSqlNormalizerTest method testNormalizedSql_cache_expire.
@Test
public void testNormalizedSql_cache_expire() throws Exception {
CachingSqlNormalizer normalizer = new DefaultCachingSqlNormalizer(1);
ParsingResult parsingResult = normalizer.wrapSql("select * from table1");
boolean newCache = normalizer.normalizedSql(parsingResult);
Assert.assertTrue("newCacheState", newCache);
// cache expire
ParsingResult parsingResult2 = normalizer.wrapSql("select * from table2");
boolean cached = normalizer.normalizedSql(parsingResult2);
Assert.assertTrue(cached);
ParsingResult parsingResult1_recached = normalizer.wrapSql("select * from table3");
boolean newCache_parsingResult1_recached = normalizer.normalizedSql(parsingResult1_recached);
Assert.assertTrue(newCache_parsingResult1_recached);
}
use of com.navercorp.pinpoint.bootstrap.context.ParsingResult in project pinpoint by naver.
the class PreparedStatementExecuteQueryInterceptor method before.
@Override
public void before(Object target, Object[] args) {
if (isDebug) {
logger.beforeInterceptor(target, args);
}
Trace trace = traceContext.currentTraceObject();
if (trace == null) {
return;
}
SpanEventRecorder recorder = trace.traceBlockBegin();
try {
DatabaseInfo databaseInfo = (target instanceof DatabaseInfoAccessor) ? ((DatabaseInfoAccessor) target)._$PINPOINT$_getDatabaseInfo() : null;
if (databaseInfo == null) {
databaseInfo = UnKnownDatabaseInfo.INSTANCE;
}
recorder.recordServiceType(databaseInfo.getExecuteQueryType());
recorder.recordEndPoint(databaseInfo.getMultipleHost());
recorder.recordDestinationId(databaseInfo.getDatabaseId());
ParsingResult parsingResult = null;
if (target instanceof ParsingResultAccessor) {
parsingResult = ((ParsingResultAccessor) target)._$PINPOINT$_getParsingResult();
}
Map<Integer, String> bindValue = null;
if (target instanceof BindValueAccessor) {
bindValue = ((BindValueAccessor) target)._$PINPOINT$_getBindValue();
}
if (bindValue != null) {
String bindString = toBindVariable(bindValue);
recorder.recordSqlParsingResult(parsingResult, bindString);
} else {
recorder.recordSqlParsingResult(parsingResult);
}
recorder.recordApi(descriptor);
// trace.recordApi(apiId);
// Need to change where to invoke clean().
// There is cleanParameters method but it's not necessary to intercept that method.
// iBatis intentionally does not invoke it in most cases.
clean(target);
} catch (Exception e) {
if (logger.isWarnEnabled()) {
logger.warn(e.getMessage(), e);
}
}
}
use of com.navercorp.pinpoint.bootstrap.context.ParsingResult in project pinpoint by naver.
the class CassandraStatementExecuteQueryInterceptor method before.
@Override
public void before(Object target, Object[] args) {
if (isDebug) {
logger.beforeInterceptor(target, args);
}
Trace trace = traceContext.currentTraceObject();
if (trace == null) {
return;
}
SpanEventRecorder recorder = trace.traceBlockBegin();
try {
DatabaseInfo databaseInfo = (target instanceof DatabaseInfoAccessor) ? ((DatabaseInfoAccessor) target)._$PINPOINT$_getDatabaseInfo() : null;
if (databaseInfo == null) {
databaseInfo = UnKnownDatabaseInfo.INSTANCE;
}
recorder.recordServiceType(databaseInfo.getExecuteQueryType());
recorder.recordEndPoint(databaseInfo.getMultipleHost());
recorder.recordDestinationId(databaseInfo.getDatabaseId());
String sql;
if (args[0] instanceof BoundStatement) {
sql = ((BoundStatement) args[0]).preparedStatement().getQueryString();
} else if (args[0] instanceof RegularStatement) {
sql = ((RegularStatement) args[0]).getQueryString();
} else {
// we have string
sql = (String) args[0];
}
ParsingResult parsingResult = traceContext.parseSql(sql);
if (parsingResult != null) {
((ParsingResultAccessor) target)._$PINPOINT$_setParsingResult(parsingResult);
} else {
if (logger.isErrorEnabled()) {
logger.error("sqlParsing fail. parsingResult is null sql:{}", sql);
}
}
Map<Integer, String> bindValue = ((BindValueAccessor) target)._$PINPOINT$_getBindValue();
// Extracting bind variables from already-serialized is too risky
if (bindValue != null && !bindValue.isEmpty()) {
String bindString = toBindVariable(bindValue);
recorder.recordSqlParsingResult(parsingResult, bindString);
} else {
recorder.recordSqlParsingResult(parsingResult);
}
recorder.recordApi(descriptor);
clean(target);
} catch (Exception e) {
if (logger.isWarnEnabled()) {
logger.warn(e.getMessage(), e);
}
}
}
use of com.navercorp.pinpoint.bootstrap.context.ParsingResult in project pinpoint by naver.
the class WrappedSpanEventRecorder method recordSqlInfo.
@Override
public ParsingResult recordSqlInfo(String sql) {
if (sql == null) {
return null;
}
ParsingResult parsingResult = sqlMetaDataService.parseSql(sql);
recordSqlParsingResult(parsingResult);
return parsingResult;
}
use of com.navercorp.pinpoint.bootstrap.context.ParsingResult in project pinpoint by naver.
the class DefaultCachingSqlNormalizerTest method testNormalizedSql.
@Test
public void testNormalizedSql() throws Exception {
CachingSqlNormalizer normalizer = new DefaultCachingSqlNormalizer(1);
ParsingResult parsingResult = normalizer.wrapSql("select * from dual");
boolean newCache = normalizer.normalizedSql(parsingResult);
Assert.assertTrue("newCacheState", newCache);
boolean notCached = normalizer.normalizedSql(parsingResult);
Assert.assertFalse("alreadyCached", notCached);
ParsingResult alreadyCached = normalizer.wrapSql("select * from dual");
boolean notCached2 = normalizer.normalizedSql(alreadyCached);
Assert.assertFalse("alreadyCached2", notCached2);
}
Aggregations