Search in sources :

Example 46 with DefaultTracer

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());
}
Also used : HashMap(java.util.HashMap) DefaultTracer(com.newrelic.agent.tracers.DefaultTracer) Tracer(com.newrelic.agent.tracers.Tracer) OtherRootTracer(com.newrelic.agent.tracers.OtherRootTracer) MockDispatcher(com.newrelic.agent.MockDispatcher) SqlTraceConfig(com.newrelic.agent.config.SqlTraceConfig) Transaction(com.newrelic.agent.Transaction) DefaultTracer(com.newrelic.agent.tracers.DefaultTracer) ClassMethodSignature(com.newrelic.agent.tracers.ClassMethodSignature) TransactionData(com.newrelic.agent.TransactionData) ServerProp(com.newrelic.agent.config.ServerProp) Test(org.junit.Test)

Aggregations

DefaultTracer (com.newrelic.agent.tracers.DefaultTracer)46 ClassMethodSignature (com.newrelic.agent.tracers.ClassMethodSignature)24 OtherRootTracer (com.newrelic.agent.tracers.OtherRootTracer)20 SimpleMetricNameFormat (com.newrelic.agent.tracers.metricname.SimpleMetricNameFormat)19 Transaction (com.newrelic.agent.Transaction)17 Tracer (com.newrelic.agent.tracers.Tracer)16 Test (org.junit.Test)14 TransactionData (com.newrelic.agent.TransactionData)6 ClassMethodMetricNameFormat (com.newrelic.agent.tracers.metricname.ClassMethodMetricNameFormat)6 MetricNameFormat (com.newrelic.agent.tracers.metricname.MetricNameFormat)6 SqlTraceConfig (com.newrelic.agent.config.SqlTraceConfig)5 OtherRootSqlTracer (com.newrelic.agent.tracers.OtherRootSqlTracer)5 JSONObject (org.json.simple.JSONObject)5 MockDispatcher (com.newrelic.agent.MockDispatcher)4 DefaultSqlTracer (com.newrelic.agent.tracers.DefaultSqlTracer)4 UltraLightTracer (com.newrelic.agent.tracers.UltraLightTracer)4 HashMap (java.util.HashMap)4 TransactionActivity (com.newrelic.agent.TransactionActivity)3 ExitTracer (com.newrelic.agent.bridge.ExitTracer)3 ServerProp (com.newrelic.agent.config.ServerProp)3