Search in sources :

Example 6 with ClassMethodSignature

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

the class NoTransactionCreateTracerTest method beforeClass.

@BeforeClass
public static void beforeClass() throws Exception {
    MockServiceManager serviceManager = new MockServiceManager();
    ServiceFactory.setServiceManager(serviceManager);
    when(cbs.isTripped()).thenReturn(false);
    serviceManager.setCircuitBreakerService(cbs);
    when(tts.isEnabled()).thenReturn(true);
    serviceManager.setTransactionTraceService(tts);
    ClassMethodSignatures.get().add(new ClassMethodSignature("firstClass", "firstMethod", "firstDesc"));
    ClassMethodSignatures.get().add(new ClassMethodSignature("secondClass", "secondMethod", "secondDesc"));
}
Also used : ClassMethodSignature(com.newrelic.agent.tracers.ClassMethodSignature) BeforeClass(org.junit.BeforeClass)

Example 7 with ClassMethodSignature

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

the class TransactionStateImplTest method tracerGeneration_segmentClampInPlace_afterRoot.

@Test
public void tracerGeneration_segmentClampInPlace_afterRoot() throws Exception {
    Tracer rootTracer = createRootTracer();
    Transaction tx = Transaction.getTransaction();
    TransactionCounts transactionCounts = tx.getTransactionCounts();
    TracerFactory tracerFactory = Mockito.mock(TracerFactory.class, new Returns(rootTracer));
    tx.getTransactionState().getTracer(tx, tracerFactory, null, null, (Object[]) null);
    assertEquals(rootTracer, tx.getTransactionActivity().getRootTracer());
    transactionCounts.addTracers(3001);
    ClassMethodSignature sig = new ClassMethodSignature("com.test.Dude", "dude1", "()V");
    Tracer tracer = tx.getTransactionState().getTracer(tx, null, sig, null, simpleFlags);
    assertNotEquals(UltraLightTracer.class, tracer.getClass());
    assertEquals("Java/com.test.Dude/dude1", tracer.getTransactionSegmentName());
    Tracer sqlTracer = tx.getTransactionState().getSqlTracer(tx, null, sig, null, simpleFlags);
    assertEquals(UltraLightTracer.class, sqlTracer.getClass());
    assertEquals("Clamped/com.test.Dude/dude1", sqlTracer.getTransactionSegmentName());
}
Also used : Returns(org.mockito.internal.stubbing.answers.Returns) ClassMethodSignature(com.newrelic.agent.tracers.ClassMethodSignature) DefaultTracer(com.newrelic.agent.tracers.DefaultTracer) UltraLightTracer(com.newrelic.agent.tracers.UltraLightTracer) Tracer(com.newrelic.agent.tracers.Tracer) OtherRootTracer(com.newrelic.agent.tracers.OtherRootTracer) TransactionCounts(com.newrelic.agent.transaction.TransactionCounts) TracerFactory(com.newrelic.agent.tracers.TracerFactory) Test(org.junit.Test)

Example 8 with ClassMethodSignature

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

the class TransactionStateImplTest method tracerMetricName_Null.

@Test
public void tracerMetricName_Null() throws Exception {
    Tracer rootTracer = createRootTracer();
    Transaction tx = Transaction.getTransaction();
    TracerFactory tracerFactory = Mockito.mock(TracerFactory.class, new Returns(rootTracer));
    tx.getTransactionState().getTracer(tx, tracerFactory, null, null, (Object[]) null);
    assertEquals(rootTracer, tx.getTransactionActivity().getRootTracer());
    ClassMethodSignature sig = new ClassMethodSignature("com.test.Dude", "dude1", "()V");
    Tracer tracer = tx.getTransactionState().getTracer(tx, null, sig, null, simpleFlags);
    assertEquals(tracer, tx.getTransactionActivity().getLastTracer());
    assertEquals("Java/com.test.Dude/dude1", tracer.getMetricName());
}
Also used : Returns(org.mockito.internal.stubbing.answers.Returns) ClassMethodSignature(com.newrelic.agent.tracers.ClassMethodSignature) DefaultTracer(com.newrelic.agent.tracers.DefaultTracer) UltraLightTracer(com.newrelic.agent.tracers.UltraLightTracer) Tracer(com.newrelic.agent.tracers.Tracer) OtherRootTracer(com.newrelic.agent.tracers.OtherRootTracer) TracerFactory(com.newrelic.agent.tracers.TracerFactory) Test(org.junit.Test)

Example 9 with ClassMethodSignature

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

the class TransactionStateImplTest method createTracer.

private Tracer createTracer() throws Exception {
    Transaction tx = Transaction.getTransaction();
    ClassMethodSignature sig = new ClassMethodSignature(getClass().getName(), "dude", "()V");
    return new DefaultTracer(tx, sig, this, new SimpleMetricNameFormat("test"));
}
Also used : ClassMethodSignature(com.newrelic.agent.tracers.ClassMethodSignature) DefaultTracer(com.newrelic.agent.tracers.DefaultTracer) SimpleMetricNameFormat(com.newrelic.agent.tracers.metricname.SimpleMetricNameFormat)

Example 10 with ClassMethodSignature

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

the class TransactionStateImplTest method tracerMetricName.

@Test
public void tracerMetricName() throws Exception {
    Tracer rootTracer = createRootTracer();
    Transaction tx = Transaction.getTransaction();
    TracerFactory tracerFactory = Mockito.mock(TracerFactory.class, new Returns(rootTracer));
    tx.getTransactionState().getTracer(tx, tracerFactory, null, null, (Object[]) null);
    assertEquals(rootTracer, tx.getTransactionActivity().getRootTracer());
    ClassMethodSignature sig = new ClassMethodSignature("com.test.Dude", "dude4", "()V");
    Tracer tracer = tx.getTransactionState().getTracer(tx, new Object(), sig, "Test/${className}/dude4", TracerFlags.CUSTOM);
    assertEquals(tracer, tx.getTransactionActivity().getLastTracer());
    assertEquals("Test/java.lang.Object/dude4", tracer.getMetricName());
}
Also used : Returns(org.mockito.internal.stubbing.answers.Returns) ClassMethodSignature(com.newrelic.agent.tracers.ClassMethodSignature) DefaultTracer(com.newrelic.agent.tracers.DefaultTracer) UltraLightTracer(com.newrelic.agent.tracers.UltraLightTracer) Tracer(com.newrelic.agent.tracers.Tracer) OtherRootTracer(com.newrelic.agent.tracers.OtherRootTracer) TracerFactory(com.newrelic.agent.tracers.TracerFactory) Test(org.junit.Test)

Aggregations

ClassMethodSignature (com.newrelic.agent.tracers.ClassMethodSignature)112 OtherRootTracer (com.newrelic.agent.tracers.OtherRootTracer)69 Transaction (com.newrelic.agent.Transaction)60 Test (org.junit.Test)55 SimpleMetricNameFormat (com.newrelic.agent.tracers.metricname.SimpleMetricNameFormat)46 DefaultTracer (com.newrelic.agent.tracers.DefaultTracer)44 Tracer (com.newrelic.agent.tracers.Tracer)41 MockHttpResponse (com.newrelic.agent.tracers.servlet.MockHttpResponse)26 MockHttpRequest (com.newrelic.agent.tracers.servlet.MockHttpRequest)23 BasicRequestRootTracer (com.newrelic.agent.tracers.servlet.BasicRequestRootTracer)20 BrowserConfigTest (com.newrelic.agent.browser.BrowserConfigTest)17 HashMap (java.util.HashMap)17 TransactionData (com.newrelic.agent.TransactionData)16 JSONObject (org.json.simple.JSONObject)15 MetricNameFormat (com.newrelic.agent.tracers.metricname.MetricNameFormat)13 UltraLightTracer (com.newrelic.agent.tracers.UltraLightTracer)12 JSONArray (org.json.simple.JSONArray)11 MethodExitTracer (com.newrelic.agent.tracers.MethodExitTracer)10 Response (com.newrelic.api.agent.Response)10 TransactionDataTestBuilder (com.newrelic.agent.TransactionDataTestBuilder)9