Search in sources :

Example 11 with ClassMethodSignature

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

the class TransactionStateImplTest method tracerMetricName_NullInvocationTarget.

@Test
public void tracerMetricName_NullInvocationTarget() 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", "dude3", "()V");
    Tracer tracer = tx.getTransactionState().getTracer(tx, null, sig, "Test/${className}/dude3", getTracerFlags(false, false, true));
    assertEquals(tracer, tx.getTransactionActivity().getLastTracer());
    assertEquals("Test/com.test.Dude/dude3", 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 12 with ClassMethodSignature

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

the class TransactionTest method createDispatcherTracer.

// Create a Tracer for tests that require one.
private Tracer createDispatcherTracer(boolean createRequest) {
    Transaction tx = Transaction.getTransaction();
    ClassMethodSignature sig = new ClassMethodSignature(getClass().getName(), "dude", "()V");
    if (createRequest) {
        MockHttpRequest httpRequest = new MockHttpRequest();
        MockHttpResponse httpResponse = new MockHttpResponse();
        return new BasicRequestRootTracer(tx, sig, this, httpRequest, httpResponse);
    } else {
        return new OtherRootTracer(tx, sig, this, new SimpleMetricNameFormat("thisismyname"));
    }
}
Also used : MockHttpRequest(com.newrelic.agent.tracers.servlet.MockHttpRequest) ClassMethodSignature(com.newrelic.agent.tracers.ClassMethodSignature) BasicRequestRootTracer(com.newrelic.agent.tracers.servlet.BasicRequestRootTracer) SimpleMetricNameFormat(com.newrelic.agent.tracers.metricname.SimpleMetricNameFormat) MockHttpResponse(com.newrelic.agent.tracers.servlet.MockHttpResponse) OtherRootTracer(com.newrelic.agent.tracers.OtherRootTracer)

Example 13 with ClassMethodSignature

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

the class SegmentTest method makeTransaction.

/**
 * Creates a transaction with one tracer and returns the root tracer (unfinished).
 */
private static Tracer makeTransaction() {
    Transaction tx = Transaction.getTransaction(true);
    TransactionActivity txa = TransactionActivity.get();
    Assert.assertNotNull(txa);
    Tracer root = new OtherRootTracer(tx, new ClassMethodSignature("com.newrelic.agent.SegmentTest", "makeTransaction", "()V"), null, DefaultTracer.NULL_METRIC_NAME_FORMATTER);
    txa.tracerStarted(root);
    tx.setTransactionName(TransactionNamePriority.FRAMEWORK_HIGH, true, "FOO", "BAR", "BAZ");
    return root;
}
Also used : ClassMethodSignature(com.newrelic.agent.tracers.ClassMethodSignature) ExitTracer(com.newrelic.agent.bridge.ExitTracer) DefaultTracer(com.newrelic.agent.tracers.DefaultTracer) Tracer(com.newrelic.agent.tracers.Tracer) OtherRootTracer(com.newrelic.agent.tracers.OtherRootTracer) OtherRootTracer(com.newrelic.agent.tracers.OtherRootTracer)

Example 14 with ClassMethodSignature

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

the class RequestUriConfigTests method startDispatcherTracer.

private Tracer startDispatcherTracer(String appName, String uri) throws Exception {
    Transaction tx = Transaction.getTransaction();
    MockHttpRequest httpRequest = new MockHttpRequest();
    httpRequest.setRequestURI(uri);
    MockHttpResponse httpResponse = new MockHttpResponse();
    ClassMethodSignature sig = new ClassMethodSignature(getClass().getName(), "dude", "()V");
    BasicRequestRootTracer requestDispatcherTracer = new BasicRequestRootTracer(tx, sig, this, httpRequest, httpResponse);
    Dispatcher dispatcher = requestDispatcherTracer.createDispatcher();
    tx.getTransactionActivity().tracerStarted(requestDispatcherTracer);
    tx.setDispatcher(dispatcher);
    tx.setApplicationName(ApplicationNamePriority.REQUEST_ATTRIBUTE, appName);
    return requestDispatcherTracer;
}
Also used : MockHttpRequest(com.newrelic.agent.tracers.servlet.MockHttpRequest) Transaction(com.newrelic.agent.Transaction) ClassMethodSignature(com.newrelic.agent.tracers.ClassMethodSignature) Dispatcher(com.newrelic.agent.dispatchers.Dispatcher) BasicRequestRootTracer(com.newrelic.agent.tracers.servlet.BasicRequestRootTracer) MockHttpResponse(com.newrelic.agent.tracers.servlet.MockHttpResponse)

Example 15 with ClassMethodSignature

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

the class BrowserConfigTest method createDispatcherTracer.

private BasicRequestRootTracer createDispatcherTracer() {
    Transaction tx = Transaction.getTransaction();
    MockHttpRequest httpRequest = new MockHttpRequest();
    MockHttpResponse httpResponse = new MockHttpResponse();
    ClassMethodSignature sig = new ClassMethodSignature(getClass().getName(), "dude", "()V");
    return new BasicRequestRootTracer(tx, sig, this, httpRequest, httpResponse);
}
Also used : MockHttpRequest(com.newrelic.agent.tracers.servlet.MockHttpRequest) Transaction(com.newrelic.agent.Transaction) ClassMethodSignature(com.newrelic.agent.tracers.ClassMethodSignature) BasicRequestRootTracer(com.newrelic.agent.tracers.servlet.BasicRequestRootTracer) MockHttpResponse(com.newrelic.agent.tracers.servlet.MockHttpResponse)

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