use of com.newrelic.agent.tracers.DefaultTracer in project newrelic-java-agent by newrelic.
the class SlowQueryInfoTest method testStandardSqlId.
@Test
public void testStandardSqlId() {
setupServiceManager(new HashMap<String, Object>());
Transaction transaction = Transaction.getTransaction();
HashMap<String, Object> sqlMap = new HashMap<>();
ServerProp serverProp = ServerProp.createPropObject(SqlTraceConfigImpl.DEFAULT_USE_LONGER_SQL_ID);
sqlMap.put(SqlTraceConfigImpl.USE_LONGER_SQL_ID, serverProp);
SqlTraceConfig sqlTraceConfig = SqlTraceConfigImpl.createSqlTraceConfig(sqlMap);
MockDispatcher dispatcher = new MockDispatcher();
dispatcher.setUri("http://jvm.agent.uri");
transaction.setDispatcher(dispatcher);
String obfuscatedQuery = "select ? from ?";
TransactionData data = new TransactionData(transaction, 100);
Tracer tracer = new DefaultTracer(transaction, new ClassMethodSignature("ClassName", "methodName", "methodDesc"), null, null, TracerFlags.DISPATCHER);
SlowQueryInfo slowQueryInfo = new SlowQueryInfo(data, tracer, "select * from person", obfuscatedQuery, sqlTraceConfig);
SqlTrace sqlTrace = slowQueryInfo.asSqlTrace();
long hashedObfuscatedQuery = (long) obfuscatedQuery.hashCode();
assertEquals(hashedObfuscatedQuery, sqlTrace.getId());
}
Aggregations