Search in sources :

Example 11 with DefaultTracer

use of com.newrelic.agent.tracers.DefaultTracer in project newrelic-java-agent by newrelic.

the class SlowQueryInfoTest method testEmptyTxnUrlRequestUriDisabled.

@Test
public void testEmptyTxnUrlRequestUriDisabled() {
    Map<String, Object> attributeMap = new HashMap<>();
    attributeMap.put("exclude", "request.*");
    Map<String, Object> settings = new HashMap<>();
    settings.put("attributes", attributeMap);
    setupServiceManager(settings);
    SqlTraceConfig sqlTraceConfig = ServiceFactory.getConfigService().getDefaultAgentConfig().getSqlTraceConfig();
    Transaction transaction = Transaction.getTransaction();
    MockDispatcher dispatcher = new MockDispatcher();
    dispatcher.setUri("http://jvm.agent.uri");
    transaction.setDispatcher(dispatcher);
    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", "select ? from ?", sqlTraceConfig);
    SqlTrace sqlTrace = slowQueryInfo.asSqlTrace();
    assertEquals(null, sqlTrace.getUri());
}
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) Test(org.junit.Test)

Example 12 with DefaultTracer

use of com.newrelic.agent.tracers.DefaultTracer in project newrelic-java-agent by newrelic.

the class SlowQueryInfoTest method testTxnUrl.

@Test
public void testTxnUrl() {
    setupServiceManager(new HashMap<String, Object>());
    Transaction transaction = Transaction.getTransaction();
    SqlTraceConfig sqlTraceConfig = ServiceFactory.getConfigService().getDefaultAgentConfig().getSqlTraceConfig();
    MockDispatcher dispatcher = new MockDispatcher();
    dispatcher.setUri("http://jvm.agent.uri");
    transaction.setDispatcher(dispatcher);
    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", "select ? from ?", sqlTraceConfig);
    SqlTrace sqlTrace = slowQueryInfo.asSqlTrace();
    assertEquals("http://jvm.agent.uri", sqlTrace.getUri());
}
Also used : SqlTraceConfig(com.newrelic.agent.config.SqlTraceConfig) Transaction(com.newrelic.agent.Transaction) DefaultTracer(com.newrelic.agent.tracers.DefaultTracer) ClassMethodSignature(com.newrelic.agent.tracers.ClassMethodSignature) DefaultTracer(com.newrelic.agent.tracers.DefaultTracer) Tracer(com.newrelic.agent.tracers.Tracer) OtherRootTracer(com.newrelic.agent.tracers.OtherRootTracer) MockDispatcher(com.newrelic.agent.MockDispatcher) TransactionData(com.newrelic.agent.TransactionData) Test(org.junit.Test)

Example 13 with DefaultTracer

use of com.newrelic.agent.tracers.DefaultTracer in project newrelic-java-agent by newrelic.

the class AsyncTest method verifyCpu.

public void verifyCpu(long minCpu) {
    Assert.assertNotNull(data);
    Assert.assertNotNull(data.getIntrinsicAttributes().get(AttributeNames.CPU_TIME_PARAMETER_NAME));
    Long val = (Long) data.getIntrinsicAttributes().get(AttributeNames.CPU_TIME_PARAMETER_NAME);
    Assert.assertTrue("The cpu should be greater than 0", val > 0);
    Assert.assertTrue("The cpu should be greater than the expeted min value " + minCpu, val > minCpu);
    long cpuTime = 0L;
    Collection<Tracer> tracers = new HashSet<>();
    tracers.add(data.getRootTracer());
    tracers.addAll(data.getTracers());
    Collection<TransactionActivity> txas = new HashSet<>();
    // collect all txas for the transaction
    for (Tracer current : tracers) {
        if (current instanceof TransactionActivityInitiator) {
            txas.add(((DefaultTracer) current).getTransactionActivity());
        }
    }
    for (TransactionActivity txa : txas) {
        cpuTime += txa.getTotalCpuTime();
    }
    Assert.assertEquals("The cpu should be sum of txa cpus ", cpuTime, val.longValue());
}
Also used : TransactionActivityInitiator(com.newrelic.agent.tracers.TransactionActivityInitiator) DefaultTracer(com.newrelic.agent.tracers.DefaultTracer) Tracer(com.newrelic.agent.tracers.Tracer) TransactionActivity(com.newrelic.agent.TransactionActivity) HashSet(java.util.HashSet)

Example 14 with DefaultTracer

use of com.newrelic.agent.tracers.DefaultTracer in project newrelic-java-agent by newrelic.

the class ExternalRequestImplTest method getTracer.

private DefaultTracer getTracer(String metricName, String transactionSegName) {
    MetricNameFormat format = new SimpleMetricNameFormat(metricName, transactionSegName);
    DefaultTracer tracer = new DefaultTracer(Transaction.getTransaction(), new ClassMethodSignature("class", "method", "()V"), new Object(), format);
    return tracer;
}
Also used : DefaultTracer(com.newrelic.agent.tracers.DefaultTracer) ClassMethodSignature(com.newrelic.agent.tracers.ClassMethodSignature) SimpleMetricNameFormat(com.newrelic.agent.tracers.metricname.SimpleMetricNameFormat) MetricNameFormat(com.newrelic.agent.tracers.metricname.MetricNameFormat) SimpleMetricNameFormat(com.newrelic.agent.tracers.metricname.SimpleMetricNameFormat)

Example 15 with DefaultTracer

use of com.newrelic.agent.tracers.DefaultTracer in project newrelic-java-agent by newrelic.

the class ExternalsForTransactionTest method createTracer.

private DefaultTracer createTracer(String metricName, String txSegName) {
    Transaction tx = Transaction.getTransaction();
    SimpleMetricNameFormat format = new SimpleMetricNameFormat(metricName, txSegName);
    DefaultTracer tracer = new DefaultTracer(tx, new ClassMethodSignature("myClass", "myMethod", "()V"), this, format);
    return tracer;
}
Also used : Transaction(com.newrelic.agent.Transaction) DefaultTracer(com.newrelic.agent.tracers.DefaultTracer) ClassMethodSignature(com.newrelic.agent.tracers.ClassMethodSignature) SimpleMetricNameFormat(com.newrelic.agent.tracers.metricname.SimpleMetricNameFormat)

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