Search in sources :

Example 71 with BasicRequestRootTracer

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

the class AttributeValidatorTest 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)

Example 72 with BasicRequestRootTracer

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

the class RPMServiceTest method doForceRestartException.

private void doForceRestartException() throws Exception {
    MockDataSenderFactory dataSenderFactory = new MockDataSenderFactory();
    DataSenderFactory.setDataSenderFactory(dataSenderFactory);
    Transaction.clearTransaction();
    List<String> appNames = singletonList("MyApplication");
    RPMService svc = new RPMService(appNames, null, null, Collections.<AgentConnectionEstablishedListener>emptyList());
    ClassMethodSignature sig = new ClassMethodSignature(getClass().getName(), "test", "()V");
    Tracer rootTracer = new BasicRequestRootTracer(Transaction.getTransaction(), sig, this, null, null, new SimpleMetricNameFormat("/test"));
    AgentConfig iAgentConfig = mock(AgentConfig.class);
    TransactionData data = new TransactionDataTestBuilder("unittest", iAgentConfig, rootTracer).setRequestUri("/unittest").build();
    List<TransactionTrace> traces = singletonList(TransactionTrace.getTransactionTrace(data));
    MockDataSender dataSender = dataSenderFactory.getLastDataSender();
    dataSender.setConnected(false);
    dataSender.setException(new ForceRestartException(""));
    CountDownLatch latch = new CountDownLatch(1);
    dataSender.setLatch(latch);
    try {
        svc.sendTransactionTraceData(traces);
    } finally {
        latch.await(10, TimeUnit.SECONDS);
        assertTrue(dataSender.isConnected());
    }
}
Also used : BasicRequestRootTracer(com.newrelic.agent.tracers.servlet.BasicRequestRootTracer) Tracer(com.newrelic.agent.tracers.Tracer) CountDownLatch(java.util.concurrent.CountDownLatch) AgentConfig(com.newrelic.agent.config.AgentConfig) ClassMethodSignature(com.newrelic.agent.tracers.ClassMethodSignature) TransactionTrace(com.newrelic.agent.trace.TransactionTrace) BasicRequestRootTracer(com.newrelic.agent.tracers.servlet.BasicRequestRootTracer) SimpleMetricNameFormat(com.newrelic.agent.tracers.metricname.SimpleMetricNameFormat)

Example 73 with BasicRequestRootTracer

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

the class RPMServiceTest method doTestTransactionTraces.

private void doTestTransactionTraces() throws Exception {
    MockDataSenderFactory dataSenderFactory = new MockDataSenderFactory();
    DataSenderFactory.setDataSenderFactory(dataSenderFactory);
    Transaction.clearTransaction();
    List<String> appNames = singletonList("MyApplication");
    RPMService svc = new RPMService(appNames, null, null, Collections.<AgentConnectionEstablishedListener>emptyList());
    svc.launch();
    ClassMethodSignature sig = new ClassMethodSignature(getClass().getName(), "test", "()V");
    Tracer rootTracer = new BasicRequestRootTracer(Transaction.getTransaction(), sig, this, null, null, new SimpleMetricNameFormat("/test"));
    AgentConfig iAgentConfig = mock(AgentConfig.class);
    TransactionData data = new TransactionDataTestBuilder("unittest", iAgentConfig, rootTracer).setRequestUri("/unittest").build();
    List<TransactionTrace> traces = singletonList(TransactionTrace.getTransactionTrace(data));
    try {
        System.err.println("Transaction trace.  JSON: " + DataSenderWriter.toJSONString(traces));
        svc.sendTransactionTraceData(traces);
    } catch (Exception e) {
        System.err.println("Error sending transaction trace.  JSON: " + DataSenderWriter.toJSONString(traces));
        throw e;
    }
    assertEquals(traces, dataSenderFactory.getLastDataSender().getTraces());
    svc.shutdown();
}
Also used : BasicRequestRootTracer(com.newrelic.agent.tracers.servlet.BasicRequestRootTracer) Tracer(com.newrelic.agent.tracers.Tracer) SSLHandshakeException(javax.net.ssl.SSLHandshakeException) AgentConfig(com.newrelic.agent.config.AgentConfig) ClassMethodSignature(com.newrelic.agent.tracers.ClassMethodSignature) TransactionTrace(com.newrelic.agent.trace.TransactionTrace) BasicRequestRootTracer(com.newrelic.agent.tracers.servlet.BasicRequestRootTracer) SimpleMetricNameFormat(com.newrelic.agent.tracers.metricname.SimpleMetricNameFormat)

Example 74 with BasicRequestRootTracer

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

the class TransactionAsyncUtility method createAndStartDispatcherTracer.

public static BasicRequestRootTracer createAndStartDispatcherTracer(Object thisObj, String methodName, MockHttpRequest httpRequest) {
    Transaction tx = Transaction.getTransaction();
    MockHttpResponse httpResponse = new MockHttpResponse();
    ClassMethodSignature sig = new ClassMethodSignature(thisObj.getClass().getName(), methodName, "()V");
    BasicRequestRootTracer brrt = new BasicRequestRootTracer(tx, sig, thisObj, httpRequest, httpResponse);
    tx.getTransactionActivity().tracerStarted(brrt);
    tx.setDispatcher(brrt.createDispatcher());
    return brrt;
}
Also used : ClassMethodSignature(com.newrelic.agent.tracers.ClassMethodSignature) BasicRequestRootTracer(com.newrelic.agent.tracers.servlet.BasicRequestRootTracer) MockHttpResponse(com.newrelic.agent.tracers.servlet.MockHttpResponse)

Example 75 with BasicRequestRootTracer

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

the class TransactionAsyncUtility method createDispatcherTracer.

// Create a Tracer for tests that require one.
public static BasicRequestRootTracer createDispatcherTracer(Object thisObj, String methodName) {
    Transaction tx = Transaction.getTransaction();
    MockHttpRequest httpRequest = new MockHttpRequest();
    MockHttpResponse httpResponse = new MockHttpResponse();
    ClassMethodSignature sig = new ClassMethodSignature(thisObj.getClass().getName(), methodName, "()V");
    BasicRequestRootTracer brrt = new BasicRequestRootTracer(tx, sig, thisObj, httpRequest, httpResponse);
    tx.setDispatcher(brrt.createDispatcher());
    return brrt;
}
Also used : MockHttpRequest(com.newrelic.agent.tracers.servlet.MockHttpRequest) ClassMethodSignature(com.newrelic.agent.tracers.ClassMethodSignature) BasicRequestRootTracer(com.newrelic.agent.tracers.servlet.BasicRequestRootTracer) MockHttpResponse(com.newrelic.agent.tracers.servlet.MockHttpResponse)

Aggregations

BasicRequestRootTracer (com.newrelic.agent.tracers.servlet.BasicRequestRootTracer)85 Test (org.junit.Test)67 Transaction (com.newrelic.agent.Transaction)64 BrowserConfigTest (com.newrelic.agent.browser.BrowserConfigTest)33 HashMap (java.util.HashMap)22 ClassMethodSignature (com.newrelic.agent.tracers.ClassMethodSignature)18 MockHttpResponse (com.newrelic.agent.tracers.servlet.MockHttpResponse)16 TransactionThrowable (com.newrelic.agent.transaction.TransactionThrowable)16 Method (java.lang.reflect.Method)16 MockHttpRequest (com.newrelic.agent.tracers.servlet.MockHttpRequest)15 SegmentTest (com.newrelic.agent.transaction.SegmentTest)15 TransactionNamePriority (com.newrelic.agent.bridge.TransactionNamePriority)14 PriorityTransactionName (com.newrelic.agent.transaction.PriorityTransactionName)14 TransactionService (com.newrelic.agent.TransactionService)8 TransactionTraceService (com.newrelic.agent.trace.TransactionTraceService)8 NewRelicApiImplementation (com.newrelic.api.agent.NewRelicApiImplementation)8 ArrayList (java.util.ArrayList)8 ImmutableMap (com.google.common.collect.ImmutableMap)7 Tracer (com.newrelic.agent.tracers.Tracer)7 InvocationTargetException (java.lang.reflect.InvocationTargetException)7